How to test a method that transfers AptosCoin to an address? #199
-
I'm new to aptos and I'm playing around with tokens, coins and transfers. I wrote a method that only transfers 1 apt to another account:
I'm writing a very simple test to test this method:
When I execute the test I get this error:
The error code seems to say that the AptosCoin is not initialized in my testing environment. Is there an extra step I have to do in order to use AptosCoin transfer on a test? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In this case, you need to initialize Here's an example: This code calls a helper function (defined in a different module), that sets up the coin, and accounts. This code here sets up the coin and the accounts associated |
Beta Was this translation helpful? Give feedback.
In this case, you need to initialize
AptosCoin
for testing. In the real networks, genesis handles this.Here's an example:
This code calls a helper function (defined in a different module), that sets up the coin, and accounts.
https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/move-examples/marketplace/sources/coin_listing.move#L666-L674
This code here sets up the coin and the accounts associated
https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/move-examples/marketplace/sources/test_utils.move#L20-L50