From 1428d5fc1dea9fcd057926da1420233215d703a3 Mon Sep 17 00:00:00 2001 From: yanmaani Date: Sat, 12 Jun 2021 12:00:00 +0000 Subject: [PATCH] test: Add integration test for name_autoregister --- test/functional/name_autoregister.py | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 test/functional/name_autoregister.py diff --git a/test/functional/name_autoregister.py b/test/functional/name_autoregister.py new file mode 100755 index 0000000000..839ad87844 --- /dev/null +++ b/test/functional/name_autoregister.py @@ -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 ()