Skip to content

Commit

Permalink
(Original diff test traces still pass)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Oct 28, 2022
1 parent 187fe36 commit 3d0bb51
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
43 changes: 37 additions & 6 deletions tests/difference/core/driver/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ func (s *CoreSuite) undelegate(val int64, amt int64) {
// consumerSlash simulates a slash event occurring on the consumer chain.
// It can be for a downtime or doublesign.
func (s *CoreSuite) consumerSlash(val int64, vscid uint64, h int64, isDowntime bool) {
consumerPubKey := s.actualVscidToMapping[vscid+s.offsetProviderVscId][val]
consumerConsAddr := providerkeeper.PubKeyToConsAddr(consumerPubKey)
// consumerPubKey := s.actualVscidToMapping[vscid+s.offsetProviderVscId][val]
// consumerConsAddr := providerkeeper.PubKeyToConsAddr(consumerPubKey)
consumerConsAddr := s.consAddr(val)

kind := stakingtypes.DoubleSign
if isDowntime {
Expand Down Expand Up @@ -352,7 +353,7 @@ func (s *CoreSuite) executeTrace() {
s.chain(C).Signers[cki2.Address().String()] = privK
_ = 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)
}
}

Expand Down Expand Up @@ -546,9 +547,40 @@ func (s *CoreSuite) TestAssumptions() {
// Test a set of traces
func (s *CoreSuite) TestTraces() {
s.traces = Traces{
Data: LoadTraces("tracesAlt.json"),
Data: LoadTraces("traces.json"),
}
s.traces.Data = []TraceData{s.traces.Data[211]}
// s.traces.Data = []TraceData{s.traces.Data[0]}
for i := range s.traces.Data {
s.Run(fmt.Sprintf("Trace num: %d", i), func() {
// Setup a new pair of chains for each trace
s.SetupTest()
s.actualVscidToMapping = map[uint64]map[int64]providerkeeper.ConsumerPubKey{}
s.actualVscidToMapping[s.offsetProviderVscId] = s.buildMapping()

s.traces.CurrentTraceIx = i
defer func() {
// If a panic occurs, we trap it to print a diagnostic
// and improve debugging experience.
if r := recover(); r != nil {
fmt.Println(s.traces.Diagnostic())
fmt.Println(r)
// Double panic to halt.
panic("Panic occurred during TestTraces")
}
}()
// Record information about the trace, for debugging
// diagnostics.
s.executeTrace()
})
}
}

// Test a set of traces
func (s *CoreSuite) TestTracesNoDowntime() {
s.traces = Traces{
Data: LoadTraces("tracesNoDowntime.json"),
}
// s.traces.Data = []TraceData{s.traces.Data[0]}
for i := range s.traces.Data {
s.Run(fmt.Sprintf("Trace num: %d", i), func() {
// Setup a new pair of chains for each trace
Expand All @@ -560,7 +592,6 @@ func (s *CoreSuite) TestTraces() {

s.actualVscidToMapping = map[uint64]map[int64]providerkeeper.ConsumerPubKey{}
s.actualVscidToMapping[s.offsetProviderVscId] = s.buildMapping()
s.actualVscidToMapping[s.offsetProviderVscId] = s.buildMapping()

s.traces.CurrentTraceIx = i
defer func() {
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas
// TODO: document better
consumerConsAddr := sdk.ConsAddress(data.Validator.Address)
providerConsAddr, err := GetProviderConsAddr(k.KeyMap(ctx, chainID), consumerConsAddr)
debugStr("recv slash, ", providerConsAddr, data)
// debugStr("recv slash, ", providerConsAddr, data)

if err != nil {
fmt.Println("could not find providerConsAddr using keymap lookup")
Expand Down Expand Up @@ -279,7 +279,7 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas
default:
return false, fmt.Errorf("invalid infraction type: %v", data.Infraction)
}
debugStr("actu slash, ", providerConsAddr, data)
// debugStr("actu slash, ", providerConsAddr, data)

// slash validator
k.stakingKeeper.Slash(
Expand Down

0 comments on commit 3d0bb51

Please sign in to comment.