forked from domob1812/namecoin-core
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add integration test for name_autoregister
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under CC0 (Public domain) | ||
|
||
# Test that name_autoregister works | ||
|
||
from test_framework.names import NameTestFramework | ||
from test_framework.util import * | ||
|
||
class NameAutoregisterTest(NameTestFramework): | ||
|
||
def set_test_params(self): | ||
self.setup_name_test ([[]] * 1) | ||
self.setup_clean_chain = True | ||
|
||
def run_test(self): | ||
node = self.nodes[0] | ||
node.generate(200) | ||
|
||
self.log.info("Register a name.") | ||
node.name_autoregister("d/name", "value") | ||
assert(len(node.listqueuedtransactions()) == 1) | ||
self.log.info("Queue contains 1 transaction.") | ||
self.log.info("Wait 12 blocks.") | ||
node.generate(12) | ||
assert(len(node.listqueuedtransactions()) == 1) | ||
node.generate(1) | ||
assert(len(node.listqueuedtransactions()) == 0) | ||
self.log.info("Queue is empty.") | ||
self.log.info("Wait 1 more block so transaction can get mined.") | ||
node.generate(1) | ||
self.checkNameData(node.name_show("d/name"), "d/name", "value", 30, False) | ||
self.log.info("Name is registered.") | ||
|
||
self.log.info("Check delegation: normal case.") | ||
node.name_autoregister("d/delegated", "value", {"delegate": True}) | ||
assert(len(node.listqueuedtransactions()) == 2) | ||
node.generate(12) | ||
assert(len(node.listqueuedtransactions()) == 2) | ||
node.generate(1) | ||
assert(len(node.listqueuedtransactions()) != 2) | ||
assert(len(node.listqueuedtransactions()) == 0) | ||
node.generate(1) | ||
self.checkNameData(node.name_show("d/delegated"), "d/delegated", '{"import":"dd/delegated"}', 30, False) | ||
self.checkNameData(node.name_show("dd/delegated"), "dd/delegated", 'value', 30, False) | ||
|
||
self.log.info("Check delegation: appending digits.") | ||
node.name_autoregister("dd/delegated2", "value") | ||
node.generate(14) | ||
node.generate(1) # hack | ||
node.name_autoregister("d/delegated2", "value", {"delegate": True}) | ||
node.generate(14) | ||
node.generate(1) | ||
self.log.info("Value is: " + node.name_show("d/delegated2")['value']) | ||
assert(node.name_show("d/delegated2")['value'] != '{"import":"dd/delegated2"}') | ||
|
||
if __name__ == '__main__': | ||
NameAutoregisterTest ().main () |