This improvement was proposed by jnewbery in #19022
We want to rewrite generate() function by using an hd seed to create addresses. This allows the test to have unique but deterministic addresses to which blocks can be generated.
TODO: Investigate why certain created keypaths do not increase incrementally/consistently:
currently, I am using a counter keypathnonce to assert every key path generated from my HD seed is unique and increment by one (maybe this was the wrong assumption to start with?).
Interestingly, when I ran tests, it seems that one particular key path,m/0'/0'/105 and m/0'/0'/106 , are always skipped. Whereas the rest of my hdkeypath increase consistently by one:
"m/0'/0'/0'
...
"m/0'/0'/101'
"m/0'/0'/102'
"m/0'/0'/103'
"m/0'/0'/104'
(skipping 105 and 106)
"m/0'/0'/107'
My assertion error
2020-06-16T15:29:57.583000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "/Users/gwang/Documents/bitcoin/test/functional/test_framework/test_framework.py", line 116, in main
self.run_test()
File "test/functional/feature_dbcrash.py", line 223, in run_test
utxo_list = create_confirmed_utxos(self.nodes[3].getnetworkinfo()['relayfee'], self.nodes[3], 5000)
File "/Users/gwang/Documents/bitcoin/test/functional/test_framework/util.py", line 547, in create_confirmed_utxos
node.generate(1)
File "/Users/gwang/Documents/bitcoin/test/functional/test_framework/test_node.py", line 307, in generate
assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(self.hdkeypathnonce)+"'")
File "/Users/gwang/Documents/bitcoin/test/functional/test_framework/util.py", line 46, in assert_equal
raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
AssertionError: not(m/0'/0'/107' == m/0'/0'/105')