Skip to content

Commit

Permalink
cp
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Oct 27, 2022
1 parent d2f971d commit 0ae42ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/difference/core/driver/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (s *CoreSuite) executeTrace() {
ck := testutil.GetTMCryptoPublicKeyFromSeed(uint64(k))
_ = pk
_ = ck
s.providerKeeper().KeyMap(s.ctx(P), s.chainID(C)).SetProviderPubKeyToConsumerPubKey(pk, ck)
// s.providerKeeper().KeyMap(s.ctx(P), s.chainID(C)).SetProviderPubKeyToConsumerPubKey(pk, ck)
}

switch a.Kind {
Expand Down
32 changes: 23 additions & 9 deletions tests/difference/core/driver/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"

Expand Down Expand Up @@ -59,6 +60,24 @@ type Builder struct {
initState InitState
}

type ValidatorKeyData struct {
signer mock.PV
address sdk.ValAddress
pubKey crypto.PubKey
}

func (b *Builder) getValidatorKeyData(seedIx int) ValidatorKeyData {
ret := ValidatorKeyData{}
ret.signer = b.getValidatorPK(seedIx)
pubKey, err := ret.signer.GetPubKey()
require.NoError(b.suite.T(), err)
ret.pubKey = pubKey
addr, err := sdk.ValAddressFromHex(ret.pubKey.Address().String())
require.NoError(b.suite.T(), err)
ret.address = addr
return ret
}

func (b *Builder) ctx(chain string) sdk.Context {
return b.chain(chain).GetContext()
}
Expand Down Expand Up @@ -317,21 +336,16 @@ func (b *Builder) createValidators() (*tmtypes.ValidatorSet, map[string]tmtypes.
}
// TODO: I think I can get in here and mimic this, and then things
// should work.
privVal := b.getValidatorPK(i)

pubKey, err := privVal.GetPubKey()
require.NoError(b.suite.T(), err)
validatorKeyData := b.getValidatorKeyData(i)

// Compute address
addr, err := sdk.ValAddressFromHex(pubKey.Address().String())
require.NoError(b.suite.T(), err)
addresses = append(addresses, addr)
addresses = append(addresses, validatorKeyData.address)

// Save signer
signers[pubKey.Address().String()] = privVal
signers[validatorKeyData.address.String()] = validatorKeyData.signer

// Save validator with power
validators = append(validators, tmtypes.NewValidator(pubKey, int64(power)))
validators = append(validators, tmtypes.NewValidator(validatorKeyData.pubKey, int64(power)))
}

return tmtypes.NewValidatorSet(validators), signers, addresses
Expand Down

0 comments on commit 0ae42ed

Please sign in to comment.