From 14a045a21798f07be15c2028ff49b974fe3388b5 Mon Sep 17 00:00:00 2001 From: Cirrus Gai Date: Wed, 13 Nov 2024 14:59:22 +0800 Subject: [PATCH] fix: Ignore duplicated sig error (#30) * ignore duplicated sig error * changelog --- CHANGELOG.md | 4 ++++ clientcontroller/babylon.go | 4 ++++ clientcontroller/retry_utils.go | 4 +++- itest/e2e_test.go | 13 ++++++++++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c264cf..ed69ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased +### Bug fixes + +* [#30](https://github.com/babylonlabs-io/covenant-emulator/pull/30) Ignore duplicated sig error + ### Improvements * [#22](https://github.com/babylonlabs-io/covenant-emulator/pull/22) Go releaser setup diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index 9887fd1..7ec9812 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -176,6 +176,10 @@ func (bc *BabylonController) SubmitCovenantSigs(covSigs []*types.CovenantSigs) ( return nil, err } + if res == nil { + return &types.TxResponse{}, nil + } + return &types.TxResponse{TxHash: res.TxHash, Events: res.Events}, nil } diff --git a/clientcontroller/retry_utils.go b/clientcontroller/retry_utils.go index 70d28c5..2d8fd7a 100644 --- a/clientcontroller/retry_utils.go +++ b/clientcontroller/retry_utils.go @@ -12,4 +12,6 @@ var unrecoverableErrors = []*sdkErr.Error{ btcstakingtypes.ErrInvalidCovenantSig, } -var expectedErrors = []*sdkErr.Error{} +var expectedErrors = []*sdkErr.Error{ + btcstakingtypes.ErrDuplicatedCovenantSig, +} diff --git a/itest/e2e_test.go b/itest/e2e_test.go index f160f4a..e425971 100644 --- a/itest/e2e_test.go +++ b/itest/e2e_test.go @@ -6,6 +6,8 @@ package e2etest import ( "testing" "time" + + "github.com/stretchr/testify/require" ) var ( @@ -37,5 +39,14 @@ func TestCovenantEmulatorLifeCycle(t *testing.T) { time.Sleep(10 * time.Second) // check the BTC delegation is verified - _ = tm.WaitForNVerifiedDels(t, 1) + dels := tm.WaitForNVerifiedDels(t, 1) + + // test duplicate, should expect no error + // remove covenant sigs + dels[0].CovenantSigs = nil + dels[0].BtcUndelegation.CovenantSlashingSigs = nil + dels[0].BtcUndelegation.CovenantUnbondingSigs = nil + res, err := tm.CovenantEmulator.AddCovenantSignatures(dels) + require.NoError(t, err) + require.Empty(t, res) }