Skip to content

Commit

Permalink
fix: add Solana ZRC20 in v2 migration test (v20) (#2866)
Browse files Browse the repository at this point in the history
* fix: add Solana ZRC20 in v2 migration test (v20)

* make generate
  • Loading branch information
lumtis authored Sep 11, 2024
1 parent 7876616 commit 676e7d7
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 16 deletions.
4 changes: 4 additions & 0 deletions e2e/runner/v2_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func (r *E2ERunner) upgradeZRC20s() {
// upgrade BTC ZRC20
r.Logger.Info("Upgrading BTC ZRC20")
r.upgradeZRC20(r.BTCZRC20Addr, r.BTCZRC20, big.NewInt(btcChainID), uint8(coin.CoinType_Gas))

// upgrade SOL ZRC20
r.Logger.Info("Upgrading SOL ZRC20")
r.upgradeZRC20(r.SOLZRC20Addr, r.SOLZRC20, big.NewInt(902), uint8(coin.CoinType_Gas))
}

// zrc20Caller is an interface to call ZRC20 functions
Expand Down
4 changes: 3 additions & 1 deletion zetaclient/chains/bitcoin/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ func GetBtcEventWithoutWitness(
vout1 := tx.Vout[1]
memo, found, err = bitcoin.DecodeOpReturnMemo(vout1.ScriptPubKey.Hex, tx.Txid)
if err != nil {
logger.Error().Err(err).Msgf("GetBtcEventWithoutWitness: error decoding OP_RETURN memo: %s", vout1.ScriptPubKey.Hex)
logger.Error().
Err(err).
Msgf("GetBtcEventWithoutWitness: error decoding OP_RETURN memo: %s", vout1.ScriptPubKey.Hex)
return nil, nil
}
}
Expand Down
150 changes: 135 additions & 15 deletions zetaclient/chains/bitcoin/observer/inbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {
rpcClient := createRPCClientAndLoadTx(t, chain.ChainId, preHash)

// get BTC event
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Equal(t, eventExpected, event)
})
Expand All @@ -363,7 +371,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {
rpcClient := createRPCClientAndLoadTx(t, chain.ChainId, preHash)

// get BTC event
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Equal(t, eventExpected, event)
})
Expand All @@ -378,7 +394,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {
rpcClient := createRPCClientAndLoadTx(t, chain.ChainId, preHash)

// get BTC event
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Equal(t, eventExpected, event)
})
Expand All @@ -393,7 +417,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {
rpcClient := createRPCClientAndLoadTx(t, chain.ChainId, preHash)

// get BTC event
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Equal(t, eventExpected, event)
})
Expand All @@ -408,7 +440,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {
rpcClient := createRPCClientAndLoadTx(t, chain.ChainId, preHash)

// get BTC event
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Equal(t, eventExpected, event)
})
Expand All @@ -419,7 +459,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {

// get BTC event
rpcClient := mocks.NewMockBTCRPCClient()
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Nil(t, event)
})
Expand All @@ -430,13 +478,29 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {

// modify the tx to have Vout[0] a P2SH output
tx.Vout[0].ScriptPubKey.Hex = strings.Replace(tx.Vout[0].ScriptPubKey.Hex, "0014", "a914", 1)
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Nil(t, event)

// append 1 byte to script to make it longer than 22 bytes
tx.Vout[0].ScriptPubKey.Hex = tx.Vout[0].ScriptPubKey.Hex + "00"
event, err = observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err = observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Nil(t, event)
})
Expand All @@ -447,7 +511,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {

// get BTC event
rpcClient := mocks.NewMockBTCRPCClient()
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Nil(t, event)
})
Expand All @@ -458,7 +530,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {

// get BTC event
rpcClient := mocks.NewMockBTCRPCClient()
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Nil(t, event)
})
Expand All @@ -469,7 +549,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {

// get BTC event
rpcClient := mocks.NewMockBTCRPCClient()
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Nil(t, event)
})
Expand All @@ -480,7 +568,15 @@ func TestGetBtcEventWithoutWitness(t *testing.T) {

// get BTC event
rpcClient := mocks.NewMockBTCRPCClient()
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.NoError(t, err)
require.Nil(t, event)
})
Expand All @@ -503,7 +599,15 @@ func TestGetBtcEventErrors(t *testing.T) {

// get BTC event
rpcClient := mocks.NewMockBTCRPCClient()
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.Error(t, err)
require.Nil(t, event)
})
Expand All @@ -514,7 +618,15 @@ func TestGetBtcEventErrors(t *testing.T) {

// get BTC event
rpcClient := mocks.NewMockBTCRPCClient()
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.Error(t, err)
require.Nil(t, event)
})
Expand All @@ -524,7 +636,15 @@ func TestGetBtcEventErrors(t *testing.T) {
rpcClient := mocks.NewMockBTCRPCClient()

// get BTC event
event, err := observer.GetBtcEventWithoutWitness(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee)
event, err := observer.GetBtcEventWithoutWitness(
rpcClient,
*tx,
tssAddress,
blockNumber,
log.Logger,
net,
depositorFee,
)
require.Error(t, err)
require.Nil(t, event)
})
Expand Down

0 comments on commit 676e7d7

Please sign in to comment.