Skip to content

Commit

Permalink
Merge pull request #2503 from oasislabs/pro-wh/feature/xferwl
Browse files Browse the repository at this point in the history
go staking: add isTransferPermitted tests
  • Loading branch information
pro-wh authored Dec 23, 2019
2 parents c878579 + 04b49c6 commit b4d818b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/2503.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go staking: add isTransferPermitted tests

it was desired that we have tests for this transfer permissions engine
58 changes: 58 additions & 0 deletions go/consensus/tendermint/apps/staking/transactions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package staking

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/oasislabs/oasis-core/go/common/crypto/signature"
staking "github.com/oasislabs/oasis-core/go/staking/api"
)

func TestIsTransferPermitted(t *testing.T) {
for _, tt := range []struct {
msg string
params *staking.ConsensusParameters
fromID signature.PublicKey
permitted bool
}{
{
"no disablement",
&staking.ConsensusParameters{},
signature.PublicKey{},
true,
},
{
"all disabled",
&staking.ConsensusParameters{
DisableTransfers: true,
},
signature.PublicKey{},
false,
},
{
"not whitelisted",
&staking.ConsensusParameters{
DisableTransfers: true,
UndisableTransfersFrom: map[signature.PublicKey]bool{
signature.PublicKey{1}: true,
},
},
signature.PublicKey{},
false,
},
{
"whitelisted",
&staking.ConsensusParameters{
DisableTransfers: true,
UndisableTransfersFrom: map[signature.PublicKey]bool{
signature.PublicKey{}: true,
},
},
signature.PublicKey{},
true,
},
} {
require.Equal(t, tt.permitted, isTransferPermitted(tt.params, tt.fromID), tt.msg)
}
}

0 comments on commit b4d818b

Please sign in to comment.