This repository has been archived by the owner on Apr 30, 2024. It is now read-only.
forked from celestiaorg/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for checkFraudulentStateTransition
- Loading branch information
1 parent
91be0fe
commit 7f82c06
Showing
1 changed file
with
60 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package baseapp | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/tendermint/tendermint/abci/types" | ||
) | ||
|
||
// Tests the checkFraudulentStateTransition for all possible cases. | ||
func TestCheckFraudulentStateTransition(t *testing.T) { | ||
|
||
//Case when only BeginBlock is set | ||
fraudProof := FraudProof{} | ||
fraudProof.fraudulentBeginBlock = &types.RequestBeginBlock{} | ||
result := fraudProof.checkFraudulentStateTransition() | ||
require.True(t, result) | ||
|
||
//Case when only DeliverTx is set | ||
fraudProof = FraudProof{} | ||
fraudProof.fraudulentDeliverTx = &types.RequestDeliverTx{} | ||
result = fraudProof.checkFraudulentStateTransition() | ||
require.True(t, result) | ||
|
||
//Case when only EndBlock is set | ||
fraudProof = FraudProof{} | ||
fraudProof.fraudulentEndBlock = &types.RequestEndBlock{} | ||
result = fraudProof.checkFraudulentStateTransition() | ||
require.True(t, result) | ||
|
||
//Case when both BeginBlock and DeliverTx are set | ||
fraudProof = FraudProof{} | ||
fraudProof.fraudulentBeginBlock = &types.RequestBeginBlock{} | ||
fraudProof.fraudulentDeliverTx = &types.RequestDeliverTx{} | ||
result = fraudProof.checkFraudulentStateTransition() | ||
require.False(t, result) | ||
|
||
//Case when both BeginBlock and EndBlock are set | ||
fraudProof = FraudProof{} | ||
fraudProof.fraudulentBeginBlock = &types.RequestBeginBlock{} | ||
fraudProof.fraudulentEndBlock = &types.RequestEndBlock{} | ||
result = fraudProof.checkFraudulentStateTransition() | ||
require.False(t, result) | ||
|
||
//Case when both DeliverTx and EndBlock are set | ||
fraudProof = FraudProof{} | ||
fraudProof.fraudulentDeliverTx = &types.RequestDeliverTx{} | ||
fraudProof.fraudulentEndBlock = &types.RequestEndBlock{} | ||
result = fraudProof.checkFraudulentStateTransition() | ||
require.False(t, result) | ||
|
||
//Case when both DeliverTx and EndBlock are set | ||
fraudProof = FraudProof{} | ||
fraudProof.fraudulentBeginBlock = &types.RequestBeginBlock{} | ||
fraudProof.fraudulentDeliverTx = &types.RequestDeliverTx{} | ||
fraudProof.fraudulentEndBlock = &types.RequestEndBlock{} | ||
result = fraudProof.checkFraudulentStateTransition() | ||
require.False(t, result) | ||
|
||
} |