* x/authz: audit updates * audit with Aaron * authz: Update Authorization.Accept method * authz: add event proto definitions * update query service * authz: use typed events * refactore and rename query authorizations * remve Authorization infix from proto services * renames wip * refactoring * update tests * fix compilation * fixing gRPC query tests * fix simulation tests * few renames * more refactore * add missing file * moving export genesis to keeper * Update docs * update tests * rename event Msg attribute to MsgTypeURL * Upate Authorization interface * rollback Makefile changes * fix tests * Apply suggestions from code review Co-authored-by: Aaron Craelius <aaron@regen.network> * renames * refactore authz/exported * lint fix * authz/types refactore * comment update * conflict updates * Apply suggestions from code review Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> * authz: move storage keys to keeper * review updates * docs update * Update x/authz/client/cli/query.go Co-authored-by: Aaron Craelius <aaron@regen.network> * move codec to the root package * authz CMD info update * comment update * update imports and build flags * fix functional tests * update proto comment * fix tests * fix test Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package simulation_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/cosmos/cosmos-sdk/simapp"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/kv"
|
|
"github.com/cosmos/cosmos-sdk/x/authz"
|
|
"github.com/cosmos/cosmos-sdk/x/authz/keeper"
|
|
"github.com/cosmos/cosmos-sdk/x/authz/simulation"
|
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
)
|
|
|
|
func TestDecodeStore(t *testing.T) {
|
|
cdc := simapp.MakeTestEncodingConfig().Marshaler
|
|
dec := simulation.NewDecodeStore(cdc)
|
|
|
|
grant, _ := authz.NewGrant(banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewInt64Coin("foo", 123))), time.Now().UTC())
|
|
grantBz, err := cdc.Marshal(&grant)
|
|
require.NoError(t, err)
|
|
kvPairs := kv.Pairs{
|
|
Pairs: []kv.Pair{
|
|
{Key: []byte(keeper.GrantKey), Value: grantBz},
|
|
{Key: []byte{0x99}, Value: []byte{0x99}},
|
|
},
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
expectedLog string
|
|
}{
|
|
{"Grant", fmt.Sprintf("%v\n%v", grant, grant)},
|
|
{"other", ""},
|
|
}
|
|
|
|
for i, tt := range tests {
|
|
i, tt := i, tt
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
switch i {
|
|
case len(tests) - 1:
|
|
require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name)
|
|
default:
|
|
require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name)
|
|
}
|
|
})
|
|
}
|
|
}
|