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:
0"m/0'/0'/0'
1...
2"m/0'/0'/101'
3"m/0'/0'/102'
4"m/0'/0'/103'
5"m/0'/0'/104'
6(skipping 105 and 106)
7"m/0'/0'/107'
My assertion error
02020-06-16T15:29:57.583000Z TestFramework (ERROR): Assertion failed
1Traceback (most recent call last):
2 File "/Users/gwang/Documents/bitcoin/test/functional/test_framework/test_framework.py", line 116, in main
3 self.run_test()
4 File "test/functional/feature_dbcrash.py", line 223, in run_test
5 utxo_list = create_confirmed_utxos(self.nodes[3].getnetworkinfo()['relayfee'], self.nodes[3], 5000)
6 File "/Users/gwang/Documents/bitcoin/test/functional/test_framework/util.py", line 547, in create_confirmed_utxos
7 node.generate(1)
8 File "/Users/gwang/Documents/bitcoin/test/functional/test_framework/test_node.py", line 307, in generate
9 assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(self.hdkeypathnonce)+"'")
10 File "/Users/gwang/Documents/bitcoin/test/functional/test_framework/util.py", line 46, in assert_equal
11 raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
12AssertionError: not(m/0'/0'/107' == m/0'/0'/105')