-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
384 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Azle Examples and Tests | ||
|
||
## TLDR | ||
|
||
Use the `examples` directory to learn how to use Azle. | ||
|
||
Stable mode examples are in the `stable` directory. | ||
|
||
Experimental mode examples are in the `experimental` directory. | ||
|
||
## Examples | ||
|
||
The `examples` directory is used for both automated testing and end-developer education. Please freely peruse the examples to learn how to use Azle; It's probably the best documentation that you'll find. | ||
|
||
We use various directory names to indicate higher-level purposes: | ||
|
||
- `demo`: Intended as more complete and easy-to-understand examples | ||
- `test`: Intended as possibly more confusing and less finished examples that are used for automated testing | ||
- `end_to_end`: Simple example-based tests that call into a canister using the JavaScript agent or `dfx` | ||
- `property`: Property-based tests that attempt to test canisters under arbitrary inputs | ||
- `candid_rpc`: Tests for the Candid RPC (remote procedure call) ICP APIs (`@query`, `@update`, Candid, `IDL`, etc) | ||
- `http_server`: Tests for the HTTP Server functionality, doing away with Candid RPC and focusing on core web 2 APIs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
examples/experimental/test/end_to_end/candid_rpc/cycles/src/cycles/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { Canister, ic, nat, query, update } from 'azle/experimental'; | ||
import { canisterBalance, msgCyclesAccept, msgCyclesAvailable } from 'azle'; | ||
import { Canister, nat, query, update } from 'azle/experimental'; | ||
|
||
export default Canister({ | ||
receiveCycles: update([], nat, () => { | ||
return ic.msgCyclesAccept(ic.msgCyclesAvailable() / 2n); | ||
return msgCyclesAccept(msgCyclesAvailable() / 2n); | ||
}), | ||
getCanisterBalance: query([], nat, () => { | ||
return ic.canisterBalance(); | ||
return canisterBalance(); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.