How can I test the invocation of the fallback function by an external account of a contract using the Populus framework?

For example, this runs forever:

chain.wait.for_receipt(mycontract.transact({'value':10, 'from':accounts[1]}))

And these two simply fail:

chain.wait.for_receipt(mycontract.transact({'value':10, 'from':accounts[1]})())
chain.wait.for_receipt(mycontract.transact({'value':10, 'from':accounts[1]}).call())

I could just use one of accounts to send Ether to the contract, but how do I do that in Populus?


The solution is straightforward, you can simply use populus' web3 fixture:

web3.eth.sendTransaction({'value': 10, 
                          'from': accounts[1], 
                          'to': mycontract.address})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.