erc20-transfer-authorization

Simple approval escrow for ERC20 spending
Log | Files | Refs

commit 93da1d66bb9e29a27e693f4bac8114e02c607ae7
parent 2be890e96b69abe2420ed36b1d9a119827dac96a
Author: lash <dev@holbrook.no>
Date:   Thu,  8 Dec 2022 19:07:50 +0000

Add test for yay

Diffstat:
Mpython/erc20_transfer_authorization/transfer_authorization.py | 9+++------
Mpython/tests/test_quorum.py | 27++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/python/erc20_transfer_authorization/transfer_authorization.py b/python/erc20_transfer_authorization/transfer_authorization.py @@ -42,6 +42,7 @@ class Request: self.serial = 0 self.yay = 0 self.nay = 0 + self.result = False @classmethod @@ -51,6 +52,7 @@ class Request: o.serial = args[0] o.yay = args[1] o.nsy = args[2] + o.result = args[3] & 2 > 0 return o @@ -262,17 +264,12 @@ class TransferAuthorization(TxFactory): d.val(v[cursor:cursor+64]) cursor += 64 r = d.decode() - return Request.create(r[1], r[2], r[0], r[3], r[4], r[5], r[6]) + return Request.create(r[1], r[2], r[0], r[3], r[4], r[5], r[6], r[7]) # # def last_serial(self): # return self.contract.functions.lastSerial().call() # -# -# def next_serial(self): -# return self.contract.functions.nextSerial().call() -# -# # def requests(self, idx): # req = self.contract.functions.requests(idx).call() # return { diff --git a/python/tests/test_quorum.py b/python/tests/test_quorum.py @@ -42,7 +42,7 @@ class TestQuorum(TestBase): self.assertEqual(r['status'], 1) - def test_yay(self): + def test_register(self): (tx_hash_hex, o) = self.c.set_thresholds(self.address, self.accounts[0], 2, 2) self.rpc.do(o) o = receipt(tx_hash_hex) @@ -73,5 +73,30 @@ class TestQuorum(TestBase): self.assertEqual(request.nay, 0) + def test_simple_yay(self): + (tx_hash_hex, o) = self.c.set_thresholds(self.address, self.accounts[0], 2, 2) + self.rpc.do(o) + o = receipt(tx_hash_hex) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + (tx_hash_hex, o) = self.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) = self.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) + + o = self.c.requests(self.address, 1, sender_address=self.accounts[0]) + r = self.rpc.do(o) + request = self.c.parse_request(r) + self.assertFalse(request.result) + + if __name__ == '__main__': unittest.main()