Skip to content

Commit

Permalink
add mainnet txn
Browse files Browse the repository at this point in the history
  • Loading branch information
bitSmiley committed Jul 23, 2024
1 parent bc349f1 commit 46ceef9
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
26 changes: 26 additions & 0 deletions zetaclient/chains/bitcoin/observer/inbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,32 @@ func TestGetBtcEventFromInscription(t *testing.T) {
require.Equal(t, event, eventExpected)
})

t.Run("decode inscription ok - mainnet", func(t *testing.T) {
// The input data is from the below mainnet, but output is modified for test case
txHash2 := "7a57f987a3cb605896a5909d9ef2bf7afbf0c78f21e4118b85d00d9e4cce0c2c"
tx := testutils.LoadBTCInboundRawResult(t, TestDataDir, chain.ChainId, txHash2, false)

preHash := "c5d224963832fc0b9a597251c2342a17b25e481a88cc9119008e8f8296652697"
tx.Vin[0].Txid = preHash
tx.Vin[0].Sequence = 2
rpcClient := createRPCClientAndLoadTx(t, chain.ChainId, preHash)

memo, _ := hex.DecodeString("72f080c854647755d0d9e6f6821f6931f855b9acffd53d87433395672756d58822fd143360762109ab898626556b1c3b8d3096d2361f1297df4a41c1b429471a9aa2fc9be5f27c13b3863d6ac269e4b587d8389f8fd9649859935b0d48dea88cdb40f20c")
eventExpected := &observer.BTCInboundEvent{
FromAddress: "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y",
ToAddress: tssAddress,
Value: tx.Vout[0].Value - depositorFee,
MemoBytes: memo,
BlockNumber: blockNumber,
TxHash: tx.Txid,
}

// get BTC event
event, err := observer.GetBtcEventWithWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
require.NoError(t, err)
require.Equal(t, event, eventExpected)
})

t.Run("should skip tx if receiver address is not TSS address", func(t *testing.T) {
// load tx and modify receiver address to any non-tss address: bc1qw8wrek2m7nlqldll66ajnwr9mh64syvkt67zlu
tx := testutils.LoadBTCInboundRawResult(t, TestDataDir, chain.ChainId, txHash, false)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"txid": "7a57f987a3cb605896a5909d9ef2bf7afbf0c78f21e4118b85d00d9e4cce0c2c",
"version": 2,
"locktime": 0,
"vin": [
{
"txid": "213403e1efb29349a48ea9717096cf20d6e19091e496052ab591f310f0deebd6",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"7a8d20a4bb100ffd6399dc4fa1972e405e0e245775be1fcd7df3d5212d62c8d2e4b5534b3ae508a1f974d8995aac759454de9645f78245b8bee3b90ade86ea70",
"20a7172b841ddb8716fd0afa3400d18bfe1105df132e6938cca651b65ee3e64853ac00634c6472f080c854647755d0d9e6f6821f6931f855b9acffd53d87433395672756d58822fd143360762109ab898626556b1c3b8d3096d2361f1297df4a41c1b429471a9aa2fc9be5f27c13b3863d6ac269e4b587d8389f8fd9649859935b0d48dea88cdb40f20c68",
"c1a7172b841ddb8716fd0afa3400d18bfe1105df132e6938cca651b65ee3e64853"
],
"sequence": 4294967295
}
],
"vout": [
{
"scriptPubKey": {
"asm": "0 daaae0d3de9d8fdee31661e61aea828b59be7864",
"hex": "0014daaae0d3de9d8fdee31661e61aea828b59be7864",
"type": "witness_v0_keyhash"
},
"value": 0.45,
"n": 0
}
]
}

0 comments on commit 46ceef9

Please sign in to comment.