forked from cosmos/relayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix account sequence mismatch errors (cosmos#1007)
* Use mutex for tx account sequence query through tx broadcast, track account sequence number on chain provider * Make updateNextAccountSequence private * Retry for account sequence mismatch errors * Allow decrementing account sequence if node says it is expected * Add test for handleAccountSequenceMismatchError
- Loading branch information
Showing
3 changed files
with
79 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cosmos | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type mockAccountSequenceMismatchError struct { | ||
Expected uint64 | ||
Actual uint64 | ||
} | ||
|
||
func (err mockAccountSequenceMismatchError) Error() string { | ||
return fmt.Sprintf("account sequence mismatch, expected %d, got %d: incorrect account sequence", err.Expected, err.Actual) | ||
} | ||
|
||
func TestHandleAccountSequenceMismatchError(t *testing.T) { | ||
p := &CosmosProvider{} | ||
p.handleAccountSequenceMismatchError(mockAccountSequenceMismatchError{Actual: 9, Expected: 10}) | ||
require.Equal(t, p.nextAccountSeq, uint64(10)) | ||
} |