-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
176 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2014-2019 The Bitcoin Core developers | ||
# Copyright (c) DeFi Blockchain Developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php. | ||
"""Test burn address tracking""" | ||
|
||
from test_framework.test_framework import DefiTestFramework | ||
|
||
from test_framework.authproxy import JSONRPCException | ||
from test_framework.util import assert_equal | ||
|
||
from decimal import Decimal | ||
|
||
class TransferBurnTest(DefiTestFramework): | ||
def set_test_params(self): | ||
self.num_nodes = 1 | ||
self.setup_clean_chain = True | ||
self.extra_args = [['-txnotokens=0', '-amkheight=1', '-eunosheight=200', '-dakotaheight=1']] | ||
|
||
def run_test(self): | ||
|
||
# Burn address | ||
old_burn_address = "mfdefichainDSTBurnAddressXXXZcE1vs" | ||
burn_address = "mfburnZSAM7Gs1hpDeNaMotJXSGA7edosG" | ||
|
||
self.nodes[0].generate(101) | ||
|
||
# Create funded account address | ||
address = self.nodes[0].getnewaddress() | ||
self.nodes[0].sendtoaddress(address, 1) | ||
self.nodes[0].generate(1) | ||
|
||
# Create tokens | ||
self.nodes[0].createtoken({ | ||
"symbol": "GOLD", | ||
"name": "shiny gold", | ||
"collateralAddress": address | ||
}) | ||
self.nodes[0].generate(1) | ||
|
||
self.nodes[0].createtoken({ | ||
"symbol": "SILVER", | ||
"name": "shiny silver", | ||
"collateralAddress": address | ||
}) | ||
self.nodes[0].generate(1) | ||
|
||
# Mint tokens | ||
self.nodes[0].minttokens(["100@128"]) | ||
self.nodes[0].generate(1) | ||
|
||
self.nodes[0].minttokens(["100@129"]) | ||
self.nodes[0].generate(1) | ||
|
||
# Send tokens to burn address | ||
self.nodes[0].accounttoaccount(address, {old_burn_address:"100@128"}) | ||
self.nodes[0].generate(1) | ||
|
||
self.nodes[0].accounttoaccount(address, {old_burn_address:"100@129"}) | ||
self.nodes[0].generate(1) | ||
|
||
# Check balance | ||
result = self.nodes[0].getaccount(old_burn_address) | ||
assert_equal(result[0], "100.00000000@GOLD#128") | ||
assert_equal(result[1], "100.00000000@SILVER#129") | ||
|
||
# Move to fork height | ||
self.nodes[0].generate(200 - self.nodes[0].getblockcount()) | ||
|
||
# Check funds have moved | ||
assert_equal(len(self.nodes[0].getaccount(old_burn_address)), 0) | ||
result = self.nodes[0].getaccount(burn_address) | ||
assert_equal(result[0], "100.00000000@GOLD#128") | ||
assert_equal(result[1], "100.00000000@SILVER#129") | ||
|
||
result = self.nodes[0].listburnhistory() | ||
assert_equal(result[0]['owner'], burn_address) | ||
assert_equal(result[0]['type'], 'AccountToAccount') | ||
assert_equal(result[0]['amounts'][0], '100.00000000@SILVER#129') | ||
assert_equal(result[1]['owner'], burn_address) | ||
assert_equal(result[1]['type'], 'AccountToAccount') | ||
assert_equal(result[1]['amounts'][0], '100.00000000@GOLD#128') | ||
|
||
result = self.nodes[0].getburnaddressinfo() | ||
assert_equal(result['address'], burn_address) | ||
assert_equal(result['amount'], Decimal('0.00000000')) | ||
assert_equal(result['tokens'][0], '100.00000000@GOLD#128') | ||
assert_equal(result['tokens'][1], '100.00000000@SILVER#129') | ||
|
||
# Revert fork block | ||
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(200)) | ||
|
||
assert_equal(len(self.nodes[0].getaccount(burn_address)), 0) | ||
result = self.nodes[0].getaccount(old_burn_address) | ||
assert_equal(result[0], "100.00000000@GOLD#128") | ||
assert_equal(result[1], "100.00000000@SILVER#129") | ||
|
||
assert_equal(len(self.nodes[0].listburnhistory()), 0) | ||
|
||
result = self.nodes[0].getburnaddressinfo() | ||
assert_equal(result['address'], burn_address) | ||
assert_equal(result['amount'], Decimal('0.00000000')) | ||
assert_equal(len(result['tokens']), 0) | ||
|
||
if __name__ == '__main__': | ||
TransferBurnTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters