erc20-faucet

ERC20 token faucet
Log | Files | Refs

commit 3e2629eba7e6d506cec1fdde262282777335d529
parent d3072272d811bfd5d00dd5b927b99e1971e9c4f5
Author: nolash <dev@holbrook.no>
Date:   Sat,  1 May 2021 01:16:18 +0200

Fix test

Diffstat:
Mpython/erc20_faucet/faucet.py | 7++++---
Mpython/tests/test_basic.py | 11+++++++----
2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/python/erc20_faucet/faucet.py b/python/erc20_faucet/faucet.py @@ -78,12 +78,13 @@ class SingleShotFaucet(Faucet): def constructor(self, sender_address, token, store, accounts_index, overrider): code = SingleShotFaucet.bytecode() enc = ABIContractEncoder() - enc.uint256(0x60) + enc.uint256(0x80) enc.address(token) enc.address(store) enc.address(accounts_index) - enc.uint256(0x01) - enc.address(overrider) + enc.uint256(len(overrider)) + for r in overrider: + enc.address(r) code += enc.get() tx = self.template(sender_address, None, use_nonce=True) tx = self.set_code(tx, code) diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py @@ -44,6 +44,7 @@ class TestFaucet(EthTesterCase): o = receipt(r) r = self.conn.do(o) + self.assertEqual(r['status'], 1) self.store_address = to_checksum_address(r['contract_address']) logg.debug('store contract {}'.format(self.store_address)) @@ -57,12 +58,14 @@ class TestFaucet(EthTesterCase): self.token_address = to_checksum_address(r['contract_address']) logg.debug('token contract {}'.format(self.store_address)) - (tx_hash, o) = c.constructor(self.accounts[0], self.token_address, self.store_address, ZERO_ADDRESS, self.accounts[1]) + (tx_hash, o) = c.constructor(self.accounts[0], self.token_address, self.store_address, ZERO_ADDRESS, [self.accounts[1]]) r = self.conn.do(o) logg.debug('faucet deployed with hash {}'.format(r)) o = receipt(r) r = self.conn.do(o) + self.assertEqual(r['status'], 1) + self.address = to_checksum_address(r['contract_address']) logg.debug('faucet contract {}'.format(self.address)) @@ -70,7 +73,7 @@ class TestFaucet(EthTesterCase): def test_basic(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) c = Faucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[1]) + (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[2]) self.conn.do(o) o = receipt(tx_hash_hex) @@ -96,7 +99,7 @@ class TestFaucet(EthTesterCase): r = self.conn.do(o) self.assertEqual(r['status'], 1) - (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[1]) + (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[2]) self.conn.do(o) o = receipt(tx_hash_hex) @@ -104,7 +107,7 @@ class TestFaucet(EthTesterCase): self.assertEqual(r['status'], 1) ct = ERC20(self.chain_spec) - o = ct.balance_of(self.token_address, self.accounts[1], sender_address=self.accounts[0]) + o = ct.balance_of(self.token_address, self.accounts[2], sender_address=self.accounts[0]) r = self.conn.do(o) amount = ct.parse_balance(r)