From 9bacbab86ce61deaa1390b59c5ffb07917a81482 Mon Sep 17 00:00:00 2001 From: Kieran Prasch Date: Mon, 5 Mar 2018 14:58:48 -0800 Subject: [PATCH] [KMS-ETH]- Extend token lanuch/fetch test with newer api and a more narrative format. --- tests/entities/test_nctoken.py | 30 +++++++++++++++++++++++------- tests/test_populus_project.py | 4 ++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/tests/entities/test_nctoken.py b/tests/entities/test_nctoken.py index 39c95d96f..ab5ac5f29 100644 --- a/tests/entities/test_nctoken.py +++ b/tests/entities/test_nctoken.py @@ -4,21 +4,37 @@ from pytest import raises from nkms_eth.token import NuCypherKMSToken -def test_create_and_get_nucypherkms_token(testerchain): +def test_launch_and_fetch_nucypherkms_token(testerchain): + + # Trying to get token from blockchain before it's been published fails with raises(NoKnownAddress): NuCypherKMSToken.get(blockchain=testerchain) + # Create a token instance token = NuCypherKMSToken(blockchain=testerchain) + + # Make sure we got the name right + contract_identifier = NuCypherKMSToken._NuCypherKMSToken__contract_name + assert'NuCypherKMSToken' == contract_identifier + + # The big day... + with raises(NuCypherKMSToken.ContractDeploymentError): + token.deploy() + + # Token must be armed before deploying to the blockchain token.arm() token.deploy() + # Ensure the contract is deployed and has a valid blockchain address assert len(token._contract.address) == 42 - assert token._contract.call().totalSupply() != 0 - # assert token.contract.call().totalSupply() == 10 ** 9 - 1 + # Check that the token contract has tokens + assert token().totalSupply() != 0 + # assert token().totalSupply() == 10 ** 9 - 1 # TODO + + # Retrieve the token from the blockchain same_token = NuCypherKMSToken.get(blockchain=testerchain) - assert token._contract.address == same_token.contract.address - assert token == same_token - - + # Compare the contract address for equality + assert token._contract.address == same_token._contract.address + assert token == same_token # __eq__ diff --git a/tests/test_populus_project.py b/tests/test_populus_project.py index b21c96d64..74f086473 100644 --- a/tests/test_populus_project.py +++ b/tests/test_populus_project.py @@ -24,6 +24,6 @@ def test_nucypher_populus_project(testerchain): # ...and on the testerchain/blockchain class itself assert testerchain._project.project_dir == populus_project_dir - # Ensure that smart contacts are available, post solidity compile. - token_contract_identifier = NuCypherKMSToken.__contract_name + # Ensure that solidity smart contacts are available, post-compile. + token_contract_identifier = NuCypherKMSToken._NuCypherKMSToken__contract_name assert token_contract_identifier in testerchain._project.compiled_contract_data \ No newline at end of file