commit 1ee7aab6e22f7f0eeab26e1c8e1c2676f8522982
parent 0f7c9855033a260c29511f4bdf49b64e3963c138
Author: lash <dev@holbrook.no>
Date: Thu, 8 Dec 2022 20:45:00 +0000
Make sure results from votes are returned sanely
Diffstat:
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/python/erc20_transfer_authorization/transfer_authorization.py b/python/erc20_transfer_authorization/transfer_authorization.py
@@ -212,6 +212,24 @@ class TransferAuthorization(TxFactory):
return o
+ def check_result(self, contract_address, serial, sender_address=ZERO_ADDRESS, id_generator=None):
+ j = JSONRPCRequest(id_generator)
+ o = j.template()
+ o['method'] = 'eth_call'
+ enc = ABIContractEncoder()
+ enc.method('checkResult')
+ enc.typ(ABIContractType.UINT32)
+ enc.uintn(serial, 32)
+ data = add_0x(enc.get())
+ tx = self.template(sender_address, contract_address)
+ tx = self.set_code(tx, data)
+ o['params'].append(self.normalize(tx))
+ o['params'].append('latest')
+ o = j.finalize(o)
+ return o
+
+
+
def is_writer(self, contract_address, signer_address, sender_address=ZERO_ADDRESS, id_generator=None):
return self.writers(contract_address, signer_address, sender_address)
diff --git a/python/tests/test_app.py b/python/tests/test_app.py
@@ -55,6 +55,41 @@ class TestBasic(TestBase):
o = c.is_writer(self.address, self.accounts[3], sender_address=self.accounts[0])
r = self.rpc.do(o)
self.assertFalse(c.parse_signers(r))
+
+
+ def test_limit(self):
+ nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
+ c = TransferAuthorization(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+
+ (tx_hash_hex, o) = c.create_request(self.address, self.accounts[0], self.accounts[1], self.accounts[2], self.token_address, 1024)
+ self.rpc.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.rpc.do(o)
+ self.assertEqual(r['status'], 1)
+
+ (tx_hash_hex, o) = c.create_request(self.address, self.accounts[0], self.accounts[1], self.accounts[2], self.token_address, 1024)
+ self.rpc.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.rpc.do(o)
+ self.assertEqual(r['status'], 1)
+
+ (tx_hash_hex, o) = c.yay(self.address, self.accounts[0], 1)
+ self.rpc.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.rpc.do(o)
+ self.assertEqual(r['status'], 1)
+
+ (tx_hash_hex, o) = c.yay(self.address, self.accounts[0], 2)
+ self.rpc.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.rpc.do(o)
+ self.assertEqual(r['status'], 1)
+
+ o = self.c.check_result(self.address, 1, sender_address=self.accounts[0])
+ self.rpc.do(o)
+ print(o)
+
+
# def test_get(self):
# w = self.w3.eth.contract(abi=self.abi_wallet, address=self.address_wallet)
# t = self.w3.eth.contract(abi=self.abi_token, address=self.address_token)