Skip to content

Commit

Permalink
test: Add integration test for name_autoregister
Browse files Browse the repository at this point in the history
  • Loading branch information
yanmaani committed Oct 15, 2021
1 parent 0ef1d41 commit 8fe8c1d
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/functional/name_autoregister.py
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 ()

0 comments on commit 8fe8c1d

Please sign in to comment.