integration tests: fixing bitcoin and zcash issues : racing, missing output, invalid vout index and block-not-found

This commit is contained in:
pragmaxim
2026-01-23 12:00:38 +01:00
parent de9c4aa964
commit 76739960e2
4 changed files with 30 additions and 9 deletions

View File

@@ -512,7 +512,8 @@ func (b *BitcoinRPC) GetChainInfo() (*bchain.ChainInfo, error) {
// IsErrBlockNotFound returns true if error means block was not found
func IsErrBlockNotFound(err *bchain.RPCError) bool {
return err.Message == "Block not found" ||
err.Message == "Block height out of range"
err.Message == "Block height out of range" ||
err.Message == "Provided index is greater than the current tip"
}
// GetBlockHash returns hash of block in best-block-chain at given height.

View File

@@ -204,6 +204,8 @@ func testGetTransactionForMempool(t *testing.T, h *TestHandler) {
for txid, want := range h.TestData.TxDetails {
// reset fields that are not parsed by BlockChainParser
want.Confirmations, want.Blocktime, want.Time, want.CoinSpecificData = 0, 0, 0, nil
// Mempool endpoints may or may not include segwit witness; keep comparisons backend-agnostic.
stripWitness(want)
got, err := h.Chain.GetTransactionForMempool(txid)
if err != nil {
@@ -215,6 +217,7 @@ func testGetTransactionForMempool(t *testing.T, h *TestHandler) {
// transactions parsed from JSON may contain additional data
got.Confirmations, got.Blocktime, got.Time, got.CoinSpecificData = 0, 0, 0, nil
stripWitness(got)
if !reflect.DeepEqual(got, want) {
t.Errorf("GetTransactionForMempool() got %+#v, want %+#v", got, want)
}
@@ -248,6 +251,12 @@ func normalizeAddresses(tx *bchain.Tx, parser bchain.BlockChainParser) {
}
}
func stripWitness(tx *bchain.Tx) {
for i := range tx.Vin {
tx.Vin[i].Witness = nil
}
}
func testMempoolSync(t *testing.T, h *TestHandler) {
for i := 0; i < 3; i++ {
txs := getMempool(t, h)
@@ -334,6 +343,10 @@ func testGetBestBlockHash(t *testing.T, h *TestHandler) {
}
hh, err := h.Chain.GetBlockHash(height)
if err != nil {
if err == bchain.ErrBlockNotFound {
time.Sleep(time.Millisecond * 100)
continue
}
t.Fatal(err)
}
if hash != hh {

View File

@@ -43,13 +43,13 @@
"hex": "0014de4e79ce2048a42698e04e079e94c97fd6e012cf"
}
},
{
"value": 0.00948127,
"n": 1,
"scriptPubKey": {
"hex": "a914c9e67d2b78a38857c786ea9a2fc3e64cb6e7756487"
}
},
{
"value": 0.00948127,
"n": 1,
"scriptPubKey": {
"hex": "a914d9e303986df109b001b97b45f3a00d84b6c9d72787"
}
},
{
"value": 0.00161416,
"n": 2,

View File

@@ -39,6 +39,13 @@
"scriptPubKey": {
"hex": "00144237fc8335d817b911332fc9df26744215266b17"
}
},
{
"value": 0.00316052,
"n": 2,
"scriptPubKey": {
"hex": "a914e5bd951e8d6b10fab8cea5b103c71ae3a37b95bf87"
}
}
]
},
@@ -91,7 +98,7 @@
},
{
"value": 0.00168669,
"n": 1,
"n": 2,
"scriptPubKey": {
"hex": "a914fa793409354d909ceaf168b7b7f91a92e0b4ba8587"
}