mirror of
git://holbrook.no/erc20-demurrage-token
synced 2024-11-22 00:06:46 +01:00
WIP test rehabilitations
This commit is contained in:
parent
43b3d2b488
commit
025ef614a5
@ -14,8 +14,8 @@ import logging
|
|||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
import confini
|
import confini
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from funga.eth.signer import EIP155Signer
|
||||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
from funga.eth.keystore.dict import DictKeystore
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from chainlib.eth.nonce import (
|
from chainlib.eth.nonce import (
|
||||||
RPCNonceOracle,
|
RPCNonceOracle,
|
||||||
|
@ -20,8 +20,8 @@ from chainlib.eth.block import (
|
|||||||
block_by_number,
|
block_by_number,
|
||||||
block_by_hash,
|
block_by_hash,
|
||||||
)
|
)
|
||||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
from funga.eth.keystore.dict import DictKeystore
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from funga.eth.signer import EIP155Signer
|
||||||
from hexathon import (
|
from hexathon import (
|
||||||
strip_0x,
|
strip_0x,
|
||||||
add_0x,
|
add_0x,
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
chainlib>=0.0.9a3,<=0.1.0
|
chainlib-eth~=0.0.12
|
||||||
eth-erc20>=0.1.2a1,<0.2.0
|
eth-erc20~=0.1.2
|
||||||
crypto-dev-signer>=0.4.15a1,<=0.4.15
|
funga-eth~=0.5.1a1
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = erc20-demurrage-token
|
name = erc20-demurrage-token
|
||||||
version = 0.0.5a2
|
version = 0.0.5a4
|
||||||
description = ERC20 token with redistributed continual demurrage
|
description = ERC20 token with redistributed continual demurrage
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
@ -28,179 +28,179 @@ testdir = os.path.dirname(__file__)
|
|||||||
|
|
||||||
class TestBasic(TestDemurrageDefault):
|
class TestBasic(TestDemurrageDefault):
|
||||||
|
|
||||||
# def test_hello(self):
|
def test_hello(self):
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# o = c.actual_period(self.address, sender_address=self.accounts[0])
|
o = c.actual_period(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
#
|
|
||||||
# self.backend.time_travel(self.start_time + self.period_seconds + 1)
|
self.backend.time_travel(self.start_time + self.period_seconds + 1)
|
||||||
# o = c.actual_period(self.address, sender_address=self.accounts[0])
|
o = c.actual_period(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
#
|
|
||||||
#
|
|
||||||
# def test_balance(self):
|
def test_balance(self):
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, 1024)
|
self.assertEqual(balance, 1024)
|
||||||
#
|
|
||||||
#
|
|
||||||
# def test_apply_demurrage(self):
|
def test_apply_demurrage(self):
|
||||||
# modifier = (10 ** 38)
|
modifier = (10 ** 28)
|
||||||
#
|
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
#
|
|
||||||
# o = c.demurrage_amount(self.address, sender_address=self.accounts[0])
|
o = c.demurrage_amount(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# demurrage_amount = c.parse_demurrage_amount(r)
|
demurrage_amount = c.parse_demurrage_amount(r)
|
||||||
# self.assertEqual(modifier, demurrage_amount)
|
self.assertEqual(modifier, demurrage_amount)
|
||||||
#
|
|
||||||
# o = block_latest()
|
o = block_latest()
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# o = block_by_number(r)
|
o = block_by_number(r)
|
||||||
# b = self.rpc.do(o)
|
b = self.rpc.do(o)
|
||||||
# logg.debug('block {} start {}'.format(b['timestamp'], self.start_time))
|
logg.debug('block {} start {}'.format(b['timestamp'], self.start_time))
|
||||||
#
|
|
||||||
# self.backend.time_travel(self.start_time + 2)
|
self.backend.time_travel(self.start_time + 2)
|
||||||
# (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
(tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# o = c.demurrage_amount(self.address, sender_address=self.accounts[0])
|
o = c.demurrage_amount(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# demurrage_amount = c.parse_demurrage_amount(r)
|
demurrage_amount = c.parse_demurrage_amount(r)
|
||||||
# self.assertEqual(modifier, demurrage_amount)
|
self.assertEqual(modifier, demurrage_amount)
|
||||||
#
|
|
||||||
# self.backend.time_travel(self.start_time + 61)
|
self.backend.time_travel(self.start_time + 61)
|
||||||
# (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
(tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
# o = c.demurrage_amount(self.address, sender_address=self.accounts[0])
|
o = c.demurrage_amount(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# demurrage_amount = c.parse_demurrage_amount(r)
|
demurrage_amount = c.parse_demurrage_amount(r)
|
||||||
# modifier_base = 1000000 - self.tax_level
|
modifier_base = 1000000 - self.tax_level
|
||||||
# logg.debug('modifier base {}'.format(modifier_base))
|
logg.debug('modifier base {}'.format(modifier_base))
|
||||||
# modifier = int(modifier_base * (10 ** 32)) # 38 decimal places minus 6 (1000000)
|
modifier = int(modifier_base * (10 ** 22)) # 38 decimal places minus 6 (1000000)
|
||||||
# self.assertEqual(modifier, demurrage_amount)
|
self.assertEqual(modifier, demurrage_amount)
|
||||||
#
|
|
||||||
# self.backend.time_travel(self.start_time + 601)
|
self.backend.time_travel(self.start_time + 601)
|
||||||
# (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
(tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
# o = c.demurrage_amount(self.address, sender_address=self.accounts[0])
|
o = c.demurrage_amount(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# demurrage_amount = c.parse_demurrage_amount(r)
|
demurrage_amount = c.parse_demurrage_amount(r)
|
||||||
# modifier_base = ((1000000 - self.tax_level) / 1000000) ** 10
|
modifier_base = ((1000000 - self.tax_level) / 1000000) ** 10
|
||||||
# modifier = int(modifier_base * (10 ** 12))
|
modifier = int(modifier_base * (10 ** 12))
|
||||||
#
|
|
||||||
# rounding_tolerance_nano = 4000000 # 0.000004% precision
|
rounding_tolerance_nano = 4000000 # 0.000004% precision
|
||||||
# demurrage_amount_truncate = int(demurrage_amount / (10 ** 26)) # equals 12 decimal places
|
demurrage_amount_truncate = int(demurrage_amount / (10 ** 26)) # equals 12 decimal places
|
||||||
# self.assertGreaterEqual(modifier, demurrage_amount_truncate - rounding_tolerance_nano)
|
self.assertGreaterEqual(modifier, demurrage_amount_truncate - rounding_tolerance_nano)
|
||||||
# self.assertLessEqual(modifier, demurrage_amount_truncate)
|
self.assertLessEqual(modifier, demurrage_amount_truncate)
|
||||||
#
|
|
||||||
#
|
|
||||||
# def test_mint(self):
|
def test_mint(self):
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, 1024)
|
self.assertEqual(balance, 1024)
|
||||||
#
|
|
||||||
# (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 976)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 976)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, 2000)
|
self.assertEqual(balance, 2000)
|
||||||
#
|
|
||||||
#
|
|
||||||
# self.backend.time_travel(self.start_time + 61)
|
self.backend.time_travel(self.start_time + 61)
|
||||||
# (tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
(tx_hash, o) = c.apply_demurrage(self.address, sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, int(2000 * 0.98))
|
self.assertEqual(balance, int(2000 * 0.98))
|
||||||
#
|
|
||||||
#
|
|
||||||
# def test_minter_control(self):
|
def test_minter_control(self):
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
#
|
|
||||||
# (tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[2], 1024)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[2], 1024)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 0)
|
self.assertEqual(r['status'], 0)
|
||||||
#
|
|
||||||
# (tx_hash, o) = c.add_minter(self.address, self.accounts[1], self.accounts[1])
|
(tx_hash, o) = c.add_minter(self.address, self.accounts[1], self.accounts[1])
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 0)
|
self.assertEqual(r['status'], 0)
|
||||||
#
|
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.add_minter(self.address, self.accounts[0], self.accounts[1])
|
(tx_hash, o) = c.add_minter(self.address, self.accounts[0], self.accounts[1])
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[2], 1024)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[2], 1024)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# (tx_hash, o) = c.add_minter(self.address, self.accounts[1], self.accounts[2])
|
(tx_hash, o) = c.add_minter(self.address, self.accounts[1], self.accounts[2])
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 0)
|
self.assertEqual(r['status'], 0)
|
||||||
#
|
|
||||||
# (tx_hash, o) = c.remove_minter(self.address, self.accounts[1], self.accounts[1])
|
(tx_hash, o) = c.remove_minter(self.address, self.accounts[1], self.accounts[1])
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# (tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[2], 1024)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[2], 1024)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 0)
|
self.assertEqual(r['status'], 0)
|
||||||
#
|
|
||||||
#
|
|
||||||
def test_base_amount(self):
|
def test_base_amount(self):
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
@ -216,78 +216,78 @@ class TestBasic(TestDemurrageDefault):
|
|||||||
amount = c.parse_to_base_amount(r)
|
amount = c.parse_to_base_amount(r)
|
||||||
self.assertEqual(amount, 1020)
|
self.assertEqual(amount, 1020)
|
||||||
|
|
||||||
#
|
|
||||||
# def test_transfer(self):
|
def test_transfer(self):
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
#
|
|
||||||
# (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
#
|
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.transfer(self.address, self.accounts[1], self.accounts[2], 500)
|
(tx_hash, o) = c.transfer(self.address, self.accounts[1], self.accounts[2], 500)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, 524)
|
self.assertEqual(balance, 524)
|
||||||
#
|
|
||||||
# o = c.balance_of(self.address, self.accounts[2], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[2], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, 500)
|
self.assertEqual(balance, 500)
|
||||||
#
|
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.transfer(self.address, self.accounts[2], self.accounts[1], 500)
|
(tx_hash, o) = c.transfer(self.address, self.accounts[2], self.accounts[1], 500)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# def test_transfer_from(self):
|
def test_transfer_from(self):
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
#
|
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.approve(self.address, self.accounts[1], self.accounts[2], 500)
|
(tx_hash, o) = c.approve(self.address, self.accounts[1], self.accounts[2], 500)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, 1024)
|
self.assertEqual(balance, 1024)
|
||||||
#
|
|
||||||
# nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||||
# c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# (tx_hash, o) = c.transfer_from(self.address, self.accounts[2], self.accounts[1], self.accounts[3], 500)
|
(tx_hash, o) = c.transfer_from(self.address, self.accounts[2], self.accounts[1], self.accounts[3], 500)
|
||||||
# self.rpc.do(o)
|
self.rpc.do(o)
|
||||||
# o = receipt(tx_hash)
|
o = receipt(tx_hash)
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# self.assertEqual(r['status'], 1)
|
self.assertEqual(r['status'], 1)
|
||||||
#
|
|
||||||
# o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, 524)
|
self.assertEqual(balance, 524)
|
||||||
#
|
|
||||||
# o = c.balance_of(self.address, self.accounts[3], sender_address=self.accounts[0])
|
o = c.balance_of(self.address, self.accounts[3], sender_address=self.accounts[0])
|
||||||
# r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
# balance = c.parse_balance_of(r)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(balance, 500)
|
self.assertEqual(balance, 500)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user