ElementsProject / libwally-core

Useful primitives for wallets
Other
281 stars 135 forks source link

test/test_transaction.py: test_hash_prevouts fails with --disable-elements #387

Closed whitslack closed 1 year ago

whitslack commented 1 year ago
configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu \
    --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share \
    --sysconfdir=/etc --localstatedir=/var/lib \
    --disable-dependency-tracking --disable-silent-rules \
    --docdir=/usr/share/doc/libwally-core-0.8.9 \
    --htmldir=/usr/share/doc/libwally-core-0.8.9/html \
    --with-sysroot=/ \
    --libdir=/usr/lib64 --includedir=/usr/include/libwally \
    --enable-export-all --enable-tests --disable-elements \
    --enable-standard-secp --disable-minimal --enable-asm \
    --disable-swig-java --disable-swig-python

make

make -C src check-TESTS check-libwallycore PYTHON=python3.11

PYTHONDONTWRITEBYTECODE=1 python3.11 test/test_transaction.py
...F.....
======================================================================
FAIL: test_hash_prevouts (__main__.TransactionTests.test_hash_prevouts)
Test functions computing hash_prevouts
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/net-libs/libwally-core-0.8.9/work/libwally-core-release_0.8.9/src/test/test_transaction.py", line 297, in test_hash_prevouts
    self.assertEqual(h(out[:out_len]), expected)
AssertionError: b'600dd7563e3c16e4c9d35d4ebfef61d56daebd82d38c39aac97efa3e69d81735' != b'96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37'

----------------------------------------------------------------------
Ran 9 tests in 0.009s

The test_hash_prevouts test passes when configuring with --enable-elements --disable-standard-secp (which uses libsecp256k1-zkp at 6ec1ff6) but fails when configuring with --disable-elements --enable-standard-secp (which uses libsecp256k1 v0.3.1).

jgriffiths commented 1 year ago

--enable-standard-secp isn't relevant here. The python ctest struct definitions in src/test/util.py include the elements members, so they can't be used as is done in the hash_prevouts test because the accessors are SWIG only.

The real fix is to epxose the accessors and use them in the test as we do for PSBT. I don't have time to get to that immediately so I'll make the test elements-only and add a FIXME.

jgriffiths commented 1 year ago

Raised https://github.com/ElementsProject/libwally-core/issues/388 for the real fix and pushed a change to skip this test for non-elements builds to master.

whitslack commented 1 year ago

@jgriffiths: Thank you for so quickly addressing all of these issues. All tests are passing in all configurations now.