Update txid gtest to verify #1144 has been removed: GetTxid() and

GetHash() return the same result.
This commit is contained in:
Simon 2016-08-27 16:10:30 -07:00
parent a64f681f2c
commit 6c79b9a12a
1 changed files with 6 additions and 16 deletions

View File

@ -8,29 +8,17 @@
#include "utilstrencodings.h"
/*
* scriptSig=3045022100ba5e90204e83c5f961b67c6232c1cc6c360afd36d43fcfae0de7af2e75f4cda7022012fec415a12048dbb70511fda6195b090b56735232281dc1144409833a092edc01
* rawtx:
* withsig: 01000000015ad78be5497476bbf84869d8156761ca850b6e82e48ad1315069a3726516a3d1010000006b483045022100ba5e90204e83c5f961b67c6232c1cc6c360afd36d43fcfae0de7af2e75f4cda7022012fec415a12048dbb70511fda6195b090b56735232281dc1144409833a092edc012102c322382e17c9ed4f47183f219cc5dd7853f939fb8eebae3c943622e0abf8d5e5feffffff0280969800000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988acd694693a000000001976a9145f0d00adba6489150808feb4108d7be582cbb2e188ac0a000000
* without: 01000000015ad78be5497476bbf84869d8156761ca850b6e82e48ad1315069a3726516a3d10100000000feffffff0280969800000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988acd694693a000000001976a9145f0d00adba6489150808feb4108d7be582cbb2e188ac0a000000
Test that removing #1144 succeeded by verifying that the hash and txid of transactions are the same.
*/
TEST(txid_tests, check_txid_and_hash_are_different) {
// Random zcash transaction 19cfa5db35f33a2e67fe1b9b738731b62e548d2f27c55a2f28523fec52b71525
TEST(txid_tests, check_txid_and_hash_are_same) {
// Random zcash transaction 0e410d5dfb44a4aa0f536605c6f6f7cc6016f39dea35ed9291ddfc402da6caaa
CTransaction tx;
CDataStream stream(ParseHex("01000000015ad78be5497476bbf84869d8156761ca850b6e82e48ad1315069a3726516a3d1010000006b483045022100ba5e90204e83c5f961b67c6232c1cc6c360afd36d43fcfae0de7af2e75f4cda7022012fec415a12048dbb70511fda6195b090b56735232281dc1144409833a092edc012102c322382e17c9ed4f47183f219cc5dd7853f939fb8eebae3c943622e0abf8d5e5feffffff0280969800000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988acd694693a000000001976a9145f0d00adba6489150808feb4108d7be582cbb2e188ac0a000000"), SER_DISK, CLIENT_VERSION);
stream >> tx;
uint256 txid = uint256S("0x19cfa5db35f33a2e67fe1b9b738731b62e548d2f27c55a2f28523fec52b71525");
ASSERT_TRUE(txid==tx.GetTxid());
uint256 hash = uint256S("0xaacaa62d40fcdd9192ed35ea9df31660ccf7f6c60566530faaa444fb5d0d410e");
ASSERT_TRUE(hash!=tx.GetTxid());
ASSERT_EQ(tx.GetHash(), tx.GetTxid());
}
/*
* coinbase txid is the double sha256, sigscript is not skipped because of BIP34.
* txid: 6041357de59ba64959d1b60f93de24dfe5ea1e26ed9e8a73d35b225a1845bad5
* raw: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03530101ffffffff02f049020000000000232102f2df427fd4f76552ed0e86b17da8cf9b07754ea23ddc05799410a4a3a5d806ccac7c9200000000000017a9146708e6670db0b950dac68031025cc5b63213a4918700000000
*/
TEST(txid_tests, check_txid_and_hash_are_same_coinbase) {
// Random zcash coinbase transaction 6041357de59ba64959d1b60f93de24dfe5ea1e26ed9e8a73d35b225a1845bad5
CTransaction tx;
@ -41,5 +29,7 @@ TEST(txid_tests, check_txid_and_hash_are_same_coinbase) {
uint256 hash = uint256S("6041357de59ba64959d1b60f93de24dfe5ea1e26ed9e8a73d35b225a1845bad5");
ASSERT_TRUE(hash==tx.GetTxid());
ASSERT_EQ(tx.GetHash(), tx.GetTxid());
}