From 6aa0d8b90368b9581aafe8b0a7d2aae1c58e7673 Mon Sep 17 00:00:00 2001 From: kevinssgh Date: Mon, 15 Apr 2024 14:44:20 -0400 Subject: [PATCH] fix test cases --- zetaclient/bitcoin/bitcoin_client_test.go | 1 + zetaclient/bitcoin/bitcoin_signer_test.go | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/zetaclient/bitcoin/bitcoin_client_test.go b/zetaclient/bitcoin/bitcoin_client_test.go index 83a7e38b3c..8992245baa 100644 --- a/zetaclient/bitcoin/bitcoin_client_test.go +++ b/zetaclient/bitcoin/bitcoin_client_test.go @@ -707,6 +707,7 @@ func TestGetBtcEventErrors(t *testing.T) { // load tx and leave rpc client without preloaded tx tx := testutils.LoadBTCIntxRawResult(t, chain.ChainId, txHash, false) rpcClient := stub.NewMockBTCRPCClient() + rpcClient.WithError(errors.New("error getting raw tx")) // get BTC event event, err := GetBtcEvent(rpcClient, *tx, tssAddress, blockNumber, log.Logger, net, depositorFee) diff --git a/zetaclient/bitcoin/bitcoin_signer_test.go b/zetaclient/bitcoin/bitcoin_signer_test.go index 96dc48cdff..59c2415202 100644 --- a/zetaclient/bitcoin/bitcoin_signer_test.go +++ b/zetaclient/bitcoin/bitcoin_signer_test.go @@ -3,6 +3,7 @@ package bitcoin import ( "encoding/hex" "fmt" + "github.com/rs/zerolog" "math" "math/big" "reflect" @@ -247,8 +248,14 @@ func createTestClientWithUTXOs(t *testing.T) *BTCChainClient { func TestAddWithdrawTxOutputs(t *testing.T) { // Create test signer and receiver address - signer, err := NewBTCSigner(config.BTCConfig{}, stub.NewTSSMainnet(), clientcommon.DefaultLoggers(), &metrics.TelemetryServer{}, nil) - require.NoError(t, err) + signer := BTCSigner{ + tssSigner: stub.NewTSSMainnet(), + rpcClient: setupBTCFallbackClient(), + logger: zerolog.Logger{}, + loggerCompliance: zerolog.Logger{}, + ts: &metrics.TelemetryServer{}, + coreContext: nil, + } // tss address and script tssAddr := signer.tssSigner.BTCAddressWitnessPubkeyHash() @@ -626,6 +633,6 @@ func TestNewBTCSigner(t *testing.T) { clientcommon.DefaultLoggers(), &metrics.TelemetryServer{}, corecontext.NewZetaCoreContext(cfg)) - require.NoError(t, err) - require.NotNil(t, btcSigner) + require.ErrorContains(t, err, "invalid endpoints") + require.Nil(t, btcSigner) }