Skip to content

Commit

Permalink
mass rename keyMap -> keyAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Nov 2, 2022
1 parent 1540f5a commit 360ec22
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
}
}

keyMap := func() *ccv.KeyAssignment {
keyAssignment := func() *ccv.KeyAssignment {
km := &ccv.KeyAssignment{}
km.ProviderConsAddrToConsumerKey = []ccv.ConsAddrToKey{}
km.ConsumerKeyToProviderKey = []ccv.KeyToKey{}
Expand All @@ -150,7 +150,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
return km
}

cs.KeyAssignment = keyMap()
cs.KeyAssignment = keyAssignment()

consumerStates = append(consumerStates, cs)
return true
Expand Down
6 changes: 3 additions & 3 deletions x/ccv/provider/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestIniAndExportGenesis(t *testing.T) {
initHeight, vscID := uint64(5), uint64(1)
ubdIndex := []uint64{0, 1, 2}
params := providertypes.DefaultParams()
keyMaps := []ccv.KeyAssignment{
keyAssignments := []ccv.KeyAssignment{
{
ProviderConsAddrToConsumerKey: []ccv.ConsAddrToKey{{ConsAddr: sdk.ConsAddress{}, Key: &tmprotocrypto.PublicKey{}}},
ConsumerKeyToProviderKey: []ccv.KeyToKey{},
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestIniAndExportGenesis(t *testing.T) {
},
nil,
[]string{"slashedValidatorConsAddress"},
&keyMaps[0],
&keyAssignments[0],
),
providertypes.NewConsumerStates(
cChainIDs[1],
Expand All @@ -67,7 +67,7 @@ func TestIniAndExportGenesis(t *testing.T) {
nil,
[]ccv.ValidatorSetChangePacketData{{ValsetUpdateId: vscID}},
nil,
&keyMaps[1],
&keyAssignments[1],
),
},
[]ccv.UnbondingOp{{
Expand Down
68 changes: 34 additions & 34 deletions x/ccv/provider/keeper/keyassignment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ const NUM_VALS = 4
// (This is constrained to ensure overlap edge cases are tested)
const NUM_CKS = 50

type keyMapEntry struct {
type keyAssignmentEntry struct {
pk providerkeeper.ProviderPublicKey
ck providerkeeper.ConsumerPublicKey
}

type traceStep struct {
keyMapEntries []keyMapEntry
providerUpdates []abci.ValidatorUpdate
timeProvider int
timeConsumer int
timeMaturity int
keyAssignmentEntries []keyAssignmentEntry
providerUpdates []abci.ValidatorUpdate
timeProvider int
timeConsumer int
timeMaturity int
}

type driver struct {
Expand Down Expand Up @@ -94,7 +94,7 @@ func makeDriver(t *testing.T, trace []traceStep) driver {
}

// Apply a list of (pk, ck) mapping requests to the KeyDel class instance
func (d *driver) applyKeyAssignmentEntries(entries []keyMapEntry) {
func (d *driver) applyKeyAssignmentEntries(entries []keyAssignmentEntry) {
for _, e := range entries {
// TRY to map provider key pk to consumer key ck.
// (May fail due to API constraints, this is correct)
Expand Down Expand Up @@ -149,7 +149,7 @@ func (d *driver) run() {
{
init := d.trace[0]
// Set the initial map
d.applyKeyAssignmentEntries(init.keyMapEntries)
d.applyKeyAssignmentEntries(init.keyAssignmentEntries)
// Set the initial provider set
d.providerValsets = append(d.providerValsets, applyUpdates(valset{}, init.providerUpdates))
// Set the initial consumer set
Expand All @@ -170,7 +170,7 @@ func (d *driver) run() {
// Provider time increase:
// Apply some new key mapping requests to KeyDel, and create new validator
// power updates.
d.applyKeyAssignmentEntries(s.keyMapEntries)
d.applyKeyAssignmentEntries(s.keyAssignmentEntries)
d.applyProviderUpdates(s.providerUpdates)

// Store the updates, to reference later in tests.
Expand Down Expand Up @@ -373,8 +373,8 @@ func (d *driver) externalInvariants() {
// which can be used to execute actions for testing.
func getTrace(t *testing.T) []traceStep {

keyMappings := func() []keyMapEntry {
ret := []keyMapEntry{}
keyAssignmentpings := func() []keyAssignmentEntry {
ret := []keyAssignmentEntry{}

const NUM_ITS = 2 // Chosen arbitrarily/heuristically
// Do this NUM_ITS times, to be able to generate conflicting mappings.
Expand All @@ -384,7 +384,7 @@ func getTrace(t *testing.T) []traceStep {
pks := rand.Perm(NUM_VALS)[0:rand.Intn(NUM_VALS+1)]
for _, pk := range pks {
ck := rand.Intn(NUM_CKS) + 100 // differentiate from pk
ret = append(ret, keyMapEntry{key(pk), key(ck)})
ret = append(ret, keyAssignmentEntry{key(pk), key(ck)})
}
}
return ret
Expand All @@ -408,20 +408,20 @@ func getTrace(t *testing.T) []traceStep {

// Get an initial key mapping.
// The real system may use some manual set defaults.
initialMappings := []keyMapEntry{}
initialMappings := []keyAssignmentEntry{}
for pk := 0; pk < NUM_VALS; pk++ {
ck := pk + 100 // differentiate from i
initialMappings = append(initialMappings, keyMapEntry{key(pk), key(ck)})
initialMappings = append(initialMappings, keyAssignmentEntry{key(pk), key(ck)})
}

ret := []traceStep{
{
// Hard code initial mapping
keyMapEntries: initialMappings,
providerUpdates: providerUpdates(),
timeProvider: 0,
timeConsumer: 0,
timeMaturity: 0,
keyAssignmentEntries: initialMappings,
providerUpdates: providerUpdates(),
timeProvider: 0,
timeConsumer: 0,
timeMaturity: 0,
},
}

Expand All @@ -432,11 +432,11 @@ func getTrace(t *testing.T) []traceStep {
// Increment provider time, and generate
// new key mappings and validator updates.
ret = append(ret, traceStep{
keyMapEntries: keyMappings(),
providerUpdates: providerUpdates(),
timeProvider: last.timeProvider + 1,
timeConsumer: last.timeConsumer,
timeMaturity: last.timeMaturity,
keyAssignmentEntries: keyAssignmentpings(),
providerUpdates: providerUpdates(),
timeProvider: last.timeProvider + 1,
timeConsumer: last.timeConsumer,
timeMaturity: last.timeMaturity,
})
}
if choice == 1 {
Expand All @@ -451,11 +451,11 @@ func getTrace(t *testing.T) []traceStep {
newTC := rand.Intn(limInclusive-curr) + curr + 1
require.True(t, curr < newTC && newTC <= limInclusive)
ret = append(ret, traceStep{
keyMapEntries: nil,
providerUpdates: nil,
timeProvider: last.timeProvider,
timeConsumer: newTC,
timeMaturity: last.timeMaturity,
keyAssignmentEntries: nil,
providerUpdates: nil,
timeProvider: last.timeProvider,
timeConsumer: newTC,
timeMaturity: last.timeMaturity,
})
}
}
Expand All @@ -469,11 +469,11 @@ func getTrace(t *testing.T) []traceStep {
newTM := rand.Intn(limInclusive-curr) + curr + 1
require.True(t, curr < newTM && newTM <= limInclusive)
ret = append(ret, traceStep{
keyMapEntries: nil,
providerUpdates: nil,
timeProvider: last.timeProvider,
timeConsumer: last.timeConsumer,
timeMaturity: newTM,
keyAssignmentEntries: nil,
providerUpdates: nil,
timeProvider: last.timeProvider,
timeConsumer: last.timeConsumer,
timeMaturity: newTM,
})
}
}
Expand Down

0 comments on commit 360ec22

Please sign in to comment.