forked from domob1812/namecoin-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpc, test: Make name value optional in name_firstupdate and name_update
- Loading branch information
1 parent
240a0b4
commit a9df3e4
Showing
4 changed files
with
100 additions
and
19 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
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,60 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under CC0 (Public domain) | ||
|
||
# Test that name_firstupdate and name_update handle missing | ||
# name values gracefully. This test uses direct RPC calls. | ||
# Testing the wrappers is out of scope. | ||
|
||
from test_framework.names import NameTestFramework | ||
from test_framework.util import * | ||
|
||
class NameNovalueTest(NameTestFramework): | ||
|
||
def set_test_params(self): | ||
self.setup_clean_chain = True | ||
self.setup_name_test ([["-namehistory", "-limitnamechains=3"]]) | ||
|
||
def run_test(self): | ||
node = self.nodes[0] | ||
node.generate(200) | ||
|
||
new_name = node.name_new("d/name") | ||
node.generate(12) | ||
self.log.info("Began registration of name.") | ||
|
||
# use node.name_firstupdate - we're not testing the framework | ||
node.name_firstupdate ("d/name", new_name[1], new_name[0]) | ||
node.generate(1) | ||
self.log.info("Name registered; no value provided.") | ||
|
||
self.checkName(0, "d/name", "", 30, False) | ||
self.log.info("Value equals empty string.") | ||
|
||
node.name_update("d/name", "1") | ||
node.generate(1) | ||
self.log.info('Value changed to "1"; change is in chain.') | ||
|
||
self.checkName(0, "d/name", "1", 30, False) | ||
self.log.info('Value equals "1".') | ||
|
||
node.name_update("d/name") | ||
node.generate(1) | ||
self.log.info("Updated; no value specified.") | ||
|
||
self.checkName(0, "d/name", "1", 30, False) | ||
self.log.info('Name was updated. Value still equals "1".') | ||
|
||
node.name_update("d/name", "2") | ||
node.name_update("d/name") | ||
node.name_update("d/name", "3") | ||
node.generate(1) | ||
self.log.info('Stack of 3 registrations performed.') | ||
|
||
history = node.name_history("d/name") | ||
reference = ["", "1", "1", "2", "2", "3"] | ||
assert(list(map(lambda x: x['value'], history)) == reference) | ||
self.log.info('Updates correctly consider updates in the mempool.') | ||
|
||
|
||
if __name__ == '__main__': | ||
NameNovalueTest ().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
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