Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

chain/test: Add ABCI begin block rolling seed test #2130

Merged
merged 2 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Chain

- (chore) [\#2130](https://github.com/bandprotocol/bandchain/pull/2130) Add ABCI begin block rolling seed test.
- (bug) [\#2075](https://github.com/bandprotocol/bandchain/pull/2075) Add height check when sync on db and fix external id can be zero.
- (bug) [\#2125](https://github.com/bandprotocol/bandchain/pull/2125) Fix request with duplicate external id and empty raw request bug.
- (chore) [\#2126](https://github.com/bandprotocol/bandchain/pull/2126) More test cleanups in request and result keepers.
Expand Down
38 changes: 38 additions & 0 deletions chain/x/oracle/abci_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package oracle_test

import (
"encoding/hex"
"testing"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/bandprotocol/bandchain/chain/x/oracle/testapp"
)

func fromHex(hexStr string) []byte {
res, err := hex.DecodeString(hexStr)
if err != nil {
panic(err)
}
return res
}

func TestRollingSeedCorrect(t *testing.T) {
app, ctx, k := testapp.CreateTestInput()
// Initially rolling seed should be all zeros.
require.Equal(t, fromHex("0000000000000000000000000000000000000000000000000000000000000000"), k.GetRollingSeed(ctx))
// Every begin block, the rolling seed should get updated.
app.BeginBlocker(ctx, abci.RequestBeginBlock{
Hash: fromHex("0100000000000000000000000000000000000000000000000000000000000000"),
})
require.Equal(t, fromHex("0000000000000000000000000000000000000000000000000000000000000001"), k.GetRollingSeed(ctx))
app.BeginBlocker(ctx, abci.RequestBeginBlock{
Hash: fromHex("0200000000000000000000000000000000000000000000000000000000000000"),
})
require.Equal(t, fromHex("0000000000000000000000000000000000000000000000000000000000000102"), k.GetRollingSeed(ctx))
app.BeginBlocker(ctx, abci.RequestBeginBlock{
Hash: fromHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
})
require.Equal(t, fromHex("00000000000000000000000000000000000000000000000000000000000102ff"), k.GetRollingSeed(ctx))
}