common/test: Fix test vector generation.

We were printing out the final merkle root before calculating it,
resulting in the final one being the same as the previous.

Reported-by: Aditya Sharma
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-07-29 15:58:46 +09:30
parent d732fa9724
commit 83d9a0005d
1 changed files with 6 additions and 5 deletions

View File

@ -383,16 +383,17 @@ int main(int argc, char *argv[])
ordered(b12,
H(LnBranch,
ordered(leaf[4], leaf[5]))))));
json_out("],");
json_out("\"merkle\": \"%s\"",
type_to_string(tmpctx, struct sha256, m));
json_out("}]");
m = H(LnBranch,
ordered(H(LnBranch,
ordered(H(LnBranch, ordered(leaf[0], leaf[1])),
H(LnBranch, ordered(leaf[2], leaf[3])))),
H(LnBranch, ordered(leaf[4], leaf[5]))));
json_out("],");
json_out("\"merkle\": \"%s\"",
type_to_string(tmpctx, struct sha256, m));
json_out("}]");
printf("offer = %s, merkle = %s\n",
tal_hex(tmpctx, all),
type_to_string(tmpctx, struct sha256, m));