eth-erc721

ERC-721 'NFT' token interface with example developer badge token contract
Log | Files | Refs | LICENSE

commit a16a31a99eedf729b6efa1cb9f746e14637987d4
parent 6ec0f053026393fe10ec92f985b42faece49fc64
Author: lash <dev@holbrook.no>
Date:   Wed,  1 Mar 2023 13:27:53 +0000

Move test code to unittest module

Diffstat:
Mpython/CHANGELOG | 6++++++
Apython/eth_badgetoken/unittest/__init__.py | 1+
Apython/eth_badgetoken/unittest/base.py | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apython/eth_erc721/unittest/__init__.py | 1+
Apython/eth_erc721/unittest/base.py | 211+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apython/eth_erc721/unittest/enum.py | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpython/setup.cfg | 6++++--
Mpython/tests/test_app.py | 253++-----------------------------------------------------------------------------
8 files changed, 347 insertions(+), 249 deletions(-)

diff --git a/python/CHANGELOG b/python/CHANGELOG @@ -1,3 +1,9 @@ +- 0.0.7 + * Move interface tests and test token publish to unittest module +- 0.0.6 + * Implement chainlib-gen for eth badgetoken' +- 0.0.5 + * Add transfer cli tool - 0.0.4 * Change license to AGPL3 and copyright waived to public domain - 0.0.3 diff --git a/python/eth_badgetoken/unittest/__init__.py b/python/eth_badgetoken/unittest/__init__.py @@ -0,0 +1 @@ +from .base import * diff --git a/python/eth_badgetoken/unittest/base.py b/python/eth_badgetoken/unittest/base.py @@ -0,0 +1,56 @@ +# standard imports +import os +import unittest +import json +import logging + +# external imports +from chainlib.eth.unittest.ethtester import EthTesterCase +from chainlib.connection import RPCConnection +from chainlib.eth.nonce import RPCNonceOracle +from chainlib.eth.address import to_checksum_address +from chainlib.eth.tx import ( + receipt, + transaction, + TxFormat, + ) +from chainlib.eth.contract import ( + abi_decode_single, + ABIContractType, + ) +from chainlib.error import JSONRPCException +from chainlib.eth.constant import ZERO_ADDRESS + + +# local imports +from eth_badgetoken import BadgeToken + +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger(__name__) + +testdir = os.path.dirname(__file__) + + +class TestBadgeToken(EthTesterCase): + + owner = None + name = 'DevBadge' + symbol = 'DEV' + #decimals = 6 + initial_supply = 0 + + def setUp(self): + super(TestBadgeToken, self).setUp() + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + #(tx_hash, o) = c.constructor(self.accounts[0], b'\x00' * 20, 'DevBadge', 'DEV') + (tx_hash, o) = c.constructor(self.accounts[0], 'DevBadge', 'DEV', self.accounts[1]) + self.conn = RPCConnection.connect(self.chain_spec, 'default') + r = self.conn.do(o) + logg.debug('deployed with hash {}'.format(r)) + + o = receipt(r) + r = self.conn.do(o) + self.address = to_checksum_address(r['contract_address']) + + TestBadgeToken.owner = self.accounts[0] diff --git a/python/eth_erc721/unittest/__init__.py b/python/eth_erc721/unittest/__init__.py @@ -0,0 +1 @@ +from .base import * diff --git a/python/eth_erc721/unittest/base.py b/python/eth_erc721/unittest/base.py @@ -0,0 +1,211 @@ +# external imports +from hexathon import strip_0x +from chainlib.eth.nonce import RPCNonceOracle +from chainlib.eth.tx import receipt +from chainlib.eth.constant import ZERO_ADDRESS +from chainlib.jsonrpc import JSONRPCException + +# local imports +from eth_badgetoken import BadgeToken + +class TestInterface: + + def _mint(self, recipient, token_id): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.mint_to(self.address, self.accounts[0], recipient, token_id) + r = self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + return c + + + def test_token_owner(self): + token_bytes = b'\xee' * 32 + token_id = int.from_bytes(token_bytes, byteorder='big') + c = self._mint(self.accounts[1], token_id) + + o = c.owner_of(self.address, token_id, sender_address=self.accounts[0]) + r = self.rpc.do(o) + owner_address = c.parse_owner(r) + self.assertEqual(strip_0x(self.accounts[1]), owner_address) + + o = c.token_of_owner_by_index(self.address, self.accounts[1], 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(token_bytes.hex(), strip_0x(r)) + + + def test_token_transfer_ownership(self): + token_bytes = [ + b'\xee' * 32, + b'\xdd' * 32, + b'\xcc' * 32, + ] + token_ids = [] + for t in token_bytes: + token_id = int.from_bytes(t, byteorder='big') + token_ids.append(token_id) + c = self._mint(self.accounts[0], token_id) + + o = c.total_supply(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + supply = c.parse_total_supply(r) + self.assertEqual(supply, 3) + + (tx_hash_hex, o) = c.transfer_ownership(self.address, self.accounts[0], self.accounts[4]) + r = self.rpc.do(o) + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + for t in token_ids: + o = c.owner_of(self.address, token_id, sender_address=self.accounts[0]) + r = self.rpc.do(o) + owner_address = c.parse_owner(r) + self.assertEqual(strip_0x(self.accounts[4]), owner_address) + + def test_mint(self): + self.backend.mine_blocks(42) + + token_bytes = b'\xee' * 32 + token_id = int.from_bytes(token_bytes, byteorder='big') + c = self._mint(self.accounts[1], token_id) + + o = c.token_by_index(self.address, 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(token_bytes.hex(), strip_0x(r)) + + o = c.total_supply(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + supply = c.parse_total_supply(r) + self.assertEqual(supply, 1) + + o = c.minted_at(self.address, token_id, sender_address=self.accounts[0]) + r = self.rpc.do(o) + height = c.parse_minted_at(r) + + self.assertEqual(height, 44) + + + def test_approve(self): + token_bytes = b'\xee' * 32 + token_id = int.from_bytes(token_bytes, byteorder='big') + c = self._mint(self.accounts[1], token_id) + + nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.approve(self.address, self.accounts[1], self.accounts[2], token_id) + r = self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.get_approved(self.address, token_id, sender_address=self.accounts[0]) + r = self.rpc.do(o) + approved_address = c.parse_get_approved(r) + self.assertEqual(approved_address, strip_0x(self.accounts[2])) + + nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.transfer_from(self.address, self.accounts[2], self.accounts[1], self.accounts[3], token_id) + r = self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.owner_of(self.address, token_id, sender_address=self.accounts[0]) + r = self.rpc.do(o) + owner_address = c.parse_owner_of(r) + self.assertEqual(owner_address, strip_0x(self.accounts[3])) + + o = c.get_approved(self.address, token_id, sender_address=self.accounts[0]) + r = self.rpc.do(o) + approved_address = c.parse_get_approved(r) + self.assertEqual(approved_address, strip_0x(ZERO_ADDRESS)) + + + def test_transfer(self): + token_bytes = b'\xee' * 32 + token_id = int.from_bytes(token_bytes, byteorder='big') + c = self._mint(self.accounts[1], token_id) + + nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.transfer_from(self.address, self.accounts[1], self.accounts[1], self.accounts[2], token_id) + r = self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.token_of_owner_by_index(self.address, self.accounts[1], 0, sender_address=self.accounts[0]) + with self.assertRaises(JSONRPCException): + r = self.rpc.do(o) + + o = c.token_of_owner_by_index(self.address, self.accounts[2], 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(token_bytes.hex(), strip_0x(r)) + + + def test_token_uri(self): + token_bytes = b'\xee' * 32 + token_id = int.from_bytes(token_bytes, byteorder='big') + c = self._mint(self.accounts[1], token_id) + + o = c.token_uri(self.address, token_id, sender_address=self.accounts[0]) + r = self.rpc.do(o) + uri = c.parse_token_uri(r) + self.assertEqual(uri, 'sha256:' + token_bytes.hex()) + + + def test_operator(self): + token_bytes = b'\xee' * 32 + token_id = int.from_bytes(token_bytes, byteorder='big') + c = self._mint(self.accounts[1], token_id) + + nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.set_operator(self.address, self.accounts[1], self.accounts[2]) + r = self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.is_operator(self.address, self.accounts[1], self.accounts[2], sender_address=self.accounts[0]) + r = self.rpc.do(o) + isop = c.parse_is_operator(r) + self.assertTrue(isop) + + (tx_hash_hex, o) = c.remove_operator(self.address, self.accounts[1], self.accounts[2]) + r = self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.is_operator(self.address, self.accounts[1], self.accounts[2], sender_address=self.accounts[0]) + r = self.rpc.do(o) + isop = c.parse_is_operator(r) + self.assertFalse(isop) + + (tx_hash_hex, o) = c.set_operator(self.address, self.accounts[1], self.accounts[2]) + r = self.rpc.do(o) + + nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.transfer_from(self.address, self.accounts[2], self.accounts[1], self.accounts[3], token_id) + r = self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.owner_of(self.address, token_id, sender_address=self.accounts[0]) + r = self.rpc.do(o) + owner_address = c.parse_owner(r) + self.assertEqual(owner_address, strip_0x(self.accounts[3])) diff --git a/python/eth_erc721/unittest/enum.py b/python/eth_erc721/unittest/enum.py @@ -0,0 +1,62 @@ +# external imports +from hexathon import strip_0x +from chainlib.eth.nonce import RPCNonceOracle +# TODO: for mint, move to cic-contracts unittest +from eth_badgetoken import BadgeToken +from chainlib.eth.tx import receipt + +# local imports +from .base import TestInterface as TestInterfaceBase + + +class TestInterface(TestInterfaceBase): + + def test_token_index(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + token_bytes = b'\xee' * 32 + token_id_one = int.from_bytes(token_bytes, byteorder='big') + (tx_hash_hex, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], token_id_one) + r = self.rpc.do(o) + + token_bytes = b'\xee' * 32 + token_id_two = int.from_bytes(token_bytes, byteorder='big') + (tx_hash_hex, o) = c.mint_to(self.address, self.accounts[0], self.accounts[2], token_id_two) + r = self.rpc.do(o) + + o = c.token_by_index(self.address, 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + token = c.parse_token_by_index(r) + self.assertEqual(token_id_one, token) + + o = c.token_by_index(self.address, 1, sender_address=self.accounts[0]) + r = self.rpc.do(o) + token = c.parse_token_by_index(r) + self.assertEqual(token_id_two, token) + + + + def test_token_owner_index(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + token_bytes = b'\xee' * 32 + token_id_one = int.from_bytes(token_bytes, byteorder='big') + (tx_hash_hex, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], token_id_one) + r = self.rpc.do(o) + + token_bytes = b'\xee' * 32 + token_id_two = int.from_bytes(token_bytes, byteorder='big') + (tx_hash_hex, o) = c.mint_to(self.address, self.accounts[0], self.accounts[2], token_id_two) + r = self.rpc.do(o) + + o = c.token_of_owner_by_index(self.address, self.accounts[1], 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + token = c.parse_token_by_index(r) + self.assertEqual(token_id_one, token) + + o = c.token_of_owner_by_index(self.address, self.accounts[2], 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + token = c.parse_token_by_index(r) + self.assertEqual(token_id_two, token) diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-erc721 -version = 0.0.6 +version = 0.0.7 description = ERC721 interface and simple contract with deployment script providing arbitrary minting of NFTs with freely settable tokenids author = Louis Holbrook author_email = dev@holbrook.no @@ -31,8 +31,10 @@ python_requires = >= 3.7 packages = eth_badgetoken eth_badgetoken.runnable + eth_badgetoken.unittest eth_badgetoken.data eth_erc721 + eth_erc721.unittest eth_erc721.runnable #eth_erc721.data #eth_erc721.runnable @@ -45,6 +47,6 @@ packages = [options.entry_points] console_scripts = - eth-badge-deploy = eth_badgetoken.runnable.deploy:main + eth-badge-publish = eth_badgetoken.runnable.publish:main eth-badge-mint = eth_badgetoken.runnable.mint:main erc721-transfer = eth_erc721.runnable.transfer:main diff --git a/python/tests/test_app.py b/python/tests/test_app.py @@ -1,260 +1,19 @@ # standard imports -import os -import unittest -import json import logging +import unittest # external imports -from chainlib.eth.unittest.ethtester import EthTesterCase -from chainlib.connection import RPCConnection -from chainlib.eth.nonce import RPCNonceOracle -from chainlib.eth.address import to_checksum_address -from chainlib.eth.tx import ( - receipt, - transaction, - TxFormat, - ) -from chainlib.eth.contract import ( - abi_decode_single, - ABIContractType, - ) -from chainlib.error import JSONRPCException -from chainlib.eth.constant import ZERO_ADDRESS -from hexathon import ( - add_0x, - strip_0x, - ) - +from eth_owned.unittest import TestInterface as TestInterfaceOwned # local imports -from eth_badgetoken import BadgeToken +from eth_badgetoken.unittest import TestBadgeToken +from eth_erc721.unittest.enum import TestInterface -logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() -testdir = os.path.dirname(__file__) - - -class Test(EthTesterCase): - - def setUp(self): - super(Test, self).setUp() - nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) - c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - #(tx_hash, o) = c.constructor(self.accounts[0], b'\x00' * 20, 'DevBadge', 'DEV') - (tx_hash, o) = c.constructor(self.accounts[0], 'DevBadge', 'DEV', self.accounts[1]) - self.conn = RPCConnection.connect(self.chain_spec, 'default') - r = self.conn.do(o) - logg.debug('deployed with hash {}'.format(r)) - - o = receipt(r) - r = self.conn.do(o) - self.address = to_checksum_address(r['contract_address']) - - - def _mint(self, recipient, token_id): - nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) - c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.mint_to(self.address, self.accounts[0], recipient, token_id) - r = self.rpc.do(o) - - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - return c - - - def test_mint(self): - self.backend.mine_blocks(42) - - token_bytes = b'\xee' * 32 - token_id = int.from_bytes(token_bytes, byteorder='big') - c = self._mint(self.accounts[1], token_id) - - o = c.token_by_index(self.address, 0, sender_address=self.accounts[0]) - r = self.rpc.do(o) - self.assertEqual(token_bytes.hex(), strip_0x(r)) - - o = c.total_supply(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - supply = c.parse_total_supply(r) - self.assertEqual(supply, 1) - - o = c.minted_at(self.address, token_id, sender_address=self.accounts[0]) - r = self.rpc.do(o) - height = c.parse_minted_at(r) - - self.assertEqual(height, 44) - - - def test_owner(self): - token_bytes = b'\xee' * 32 - token_id = int.from_bytes(token_bytes, byteorder='big') - c = self._mint(self.accounts[1], token_id) - - o = c.owner_of(self.address, token_id, sender_address=self.accounts[0]) - r = self.rpc.do(o) - owner_address = c.parse_owner_of(r) - self.assertEqual(strip_0x(self.accounts[1]), owner_address) - - o = c.token_of_owner_by_index(self.address, self.accounts[1], 0, sender_address=self.accounts[0]) - r = self.rpc.do(o) - self.assertEqual(token_bytes.hex(), strip_0x(r)) - - - def test_approve(self): - token_bytes = b'\xee' * 32 - token_id = int.from_bytes(token_bytes, byteorder='big') - c = self._mint(self.accounts[1], token_id) - - nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) - c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.approve(self.address, self.accounts[1], self.accounts[2], token_id) - r = self.rpc.do(o) - - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - o = c.get_approved(self.address, token_id, sender_address=self.accounts[0]) - r = self.rpc.do(o) - approved_address = c.parse_get_approved(r) - self.assertEqual(approved_address, strip_0x(self.accounts[2])) - - nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc) - c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.transfer_from(self.address, self.accounts[2], self.accounts[1], self.accounts[3], token_id) - r = self.rpc.do(o) - - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - o = c.owner_of(self.address, token_id, sender_address=self.accounts[0]) - r = self.rpc.do(o) - owner_address = c.parse_owner_of(r) - self.assertEqual(owner_address, strip_0x(self.accounts[3])) - - o = c.get_approved(self.address, token_id, sender_address=self.accounts[0]) - r = self.rpc.do(o) - approved_address = c.parse_get_approved(r) - self.assertEqual(approved_address, strip_0x(ZERO_ADDRESS)) - - - - - def test_operator(self): - token_bytes = b'\xee' * 32 - token_id = int.from_bytes(token_bytes, byteorder='big') - c = self._mint(self.accounts[1], token_id) - - nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) - c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.set_operator(self.address, self.accounts[1], self.accounts[2]) - r = self.rpc.do(o) - - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - o = c.is_operator(self.address, self.accounts[1], self.accounts[2], sender_address=self.accounts[0]) - r = self.rpc.do(o) - isop = c.parse_is_operator(r) - self.assertTrue(isop) - - (tx_hash_hex, o) = c.remove_operator(self.address, self.accounts[1], self.accounts[2]) - r = self.rpc.do(o) - - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - o = c.is_operator(self.address, self.accounts[1], self.accounts[2], sender_address=self.accounts[0]) - r = self.rpc.do(o) - isop = c.parse_is_operator(r) - self.assertFalse(isop) - - (tx_hash_hex, o) = c.set_operator(self.address, self.accounts[1], self.accounts[2]) - r = self.rpc.do(o) - - nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc) - c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.transfer_from(self.address, self.accounts[2], self.accounts[1], self.accounts[3], token_id) - r = self.rpc.do(o) - - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - o = c.owner_of(self.address, token_id, sender_address=self.accounts[0]) - r = self.rpc.do(o) - owner_address = c.parse_owner_of(r) - self.assertEqual(owner_address, strip_0x(self.accounts[3])) - - - def test_transfer(self): - token_bytes = b'\xee' * 32 - token_id = int.from_bytes(token_bytes, byteorder='big') - c = self._mint(self.accounts[1], token_id) - - nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) - c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.transfer_from(self.address, self.accounts[1], self.accounts[1], self.accounts[2], token_id) - r = self.rpc.do(o) - - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - o = c.token_of_owner_by_index(self.address, self.accounts[1], 0, sender_address=self.accounts[0]) - with self.assertRaises(JSONRPCException): - r = self.rpc.do(o) - - o = c.token_of_owner_by_index(self.address, self.accounts[2], 0, sender_address=self.accounts[0]) - r = self.rpc.do(o) - self.assertEqual(token_bytes.hex(), strip_0x(r)) - - - def test_contract_ownership(self): - token_bytes = [ - b'\xee' * 32, - b'\xdd' * 32, - b'\xcc' * 32, - ] - token_ids = [] - for t in token_bytes: - token_id = int.from_bytes(t, byteorder='big') - token_ids.append(token_id) - c = self._mint(self.accounts[0], token_id) - - o = c.total_supply(self.address, sender_address=self.accounts[0]) - r = self.rpc.do(o) - supply = c.parse_total_supply(r) - self.assertEqual(supply, 3) - - (tx_hash_hex, o) = c.transfer_ownership(self.address, self.accounts[0], self.accounts[4]) - r = self.rpc.do(o) - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - for t in token_ids: - o = c.owner_of(self.address, token_id, sender_address=self.accounts[0]) - r = self.rpc.do(o) - owner_address = c.parse_owner_of(r) - self.assertEqual(strip_0x(self.accounts[4]), owner_address) - - - def test_token_uri(self): - token_bytes = b'\xee' * 32 - token_id = int.from_bytes(token_bytes, byteorder='big') - c = self._mint(self.accounts[1], token_id) - o = c.token_uri(self.address, token_id, sender_address=self.accounts[0]) - r = self.rpc.do(o) - uri = c.parse_token_uri(r) - self.assertEqual(uri, 'sha256:' + token_bytes.hex()) +class TestBasic(TestBadgeToken, TestInterface, TestInterfaceOwned): + pass if __name__ == '__main__':