Send funds with Unit test aeproject-lib deployer instance

Hello everyone

I am trying to unit test a smart contract. I am trying to send value to a payable function that requires it to execute.

So far, What I am doing is deploy oracle, and store it in a new variable to call its methods (As the default template goes)

const deployedPromise = deployer.deploy(MY_CONTRACT_PATH) // Deploy it

    await assert.isFulfilled(deployedPromise, 'Could not deploy the My Smart Contract'); // Check whether it's deployed
    instance = await Promise.resolve(deployedPromise)
    console.log(instance)

Now later I want to use this instance and call a method that requires aettos to execute.

I am aware that calling like that possible with SDK passing {amount: _amount} but not sure how to do it here. Or should I use the SDK to fulfill the operation?

For example, I want to send aettos with this method.
instance.create_text(_text)

To send attos, you use the amount functionalities as shown in the below code snippet:

instance.create_text(_text, {amount: _amount})

For more tips on Unit Test Scripts, you can check out the test scripts of the SmartS hop Sophia Example at:
https://github.com/aeternity/aepp-sophia-examples/blob/master/examples/SmartShop/test/contractsTest.js

2 Likes

thank you @emmanueljet it was that, I was trying this before but wasn’t working, The problem was in contract condition which does not include = as a check, But thanks for mentioning it I rechecked and found the problem.

2 Likes