From 09553ab019fc6cd8f12e5903040b2ed8395ca139 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Sat, 4 Feb 2023 13:23:20 +0300 Subject: [PATCH] tests: add test payable receive fn with tx data Signed-off-by: lash --- .gitignore | 1 + python/requirements.txt | 2 +- python/test_requirements.txt | 2 +- python/tests/test_basic.py | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 72400e2..e281667 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build/ dist/ solidity/*.json solidity/*.bin +.venv \ No newline at end of file diff --git a/python/requirements.txt b/python/requirements.txt index b70c025..c3208b7 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,2 +1,2 @@ chainlib-eth~=0.4.8 -erc20-faucet̃~=0.5.0 +erc20-faucet~=0.5.0 diff --git a/python/test_requirements.txt b/python/test_requirements.txt index 8e69d15..9dd15f2 100644 --- a/python/test_requirements.txt +++ b/python/test_requirements.txt @@ -1,3 +1,3 @@ eth_tester==0.5.0b3 py-evm==0.3.0a20 -accounts_index~=0.3.0 +eth-accounts-index~=0.3.0 diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py index a835447..825fa36 100644 --- a/python/tests/test_basic.py +++ b/python/tests/test_basic.py @@ -129,6 +129,28 @@ class TestFaucet(EthTesterCase): r = self.conn.do(o) self.assertEqual(int(r, 16), prebalance - cost + 1000) + def test_payable_with_tx_data(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) + c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + o = balance(self.accounts[0]) + r = self.conn.do(o) + prebalance = int(r, 16) + + gas_price = 1000000000 + contract_gas_oracle = OverrideGasOracle(limit=21055, price=gas_price, conn=self.conn) + cg = Gas(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=contract_gas_oracle) + (tx_hash_hex, o) = cg.create(self.accounts[0], self.address, 1000, data='0x0') + self.conn.do(o) + + o = receipt(tx_hash_hex) + r = self.conn.do(o) + cost = r['gas_used'] * gas_price + self.assertEqual(r['status'], 0) + + o = balance(self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), prebalance - cost) def test_basic_self(self): nonce_oracle = RPCNonceOracle(self.accounts[2], self.conn)