diff --git a/tests/mbt/model/ccv.qnt b/tests/mbt/model/ccv.qnt index ead7697e67..87ddc91ea2 100644 --- a/tests/mbt/model/ccv.qnt +++ b/tests/mbt/model/ccv.qnt @@ -877,8 +877,8 @@ module ccv { }) val newConsumerState = commitPacketOnConsumer(consumerState, packet) - // add the consumer address to the list of outstanding slashes - .with("outstandingDowntime", consumerState.outstandingDowntime.union(Set(consumerNode))) + // add the consumer address to the list of outstanding downtime if the packet is a downtime slash + .with("outstandingDowntime", if (downtime) consumerState.outstandingDowntime.add(consumerNode) else consumerState.outstandingDowntime) Ok(currentState.with("consumerStates", currentState.consumerStates.set(consumer, newConsumerState))) } } diff --git a/tests/mbt/model/ccv_test.qnt b/tests/mbt/model/ccv_test.qnt index cde053c420..986f8c2532 100644 --- a/tests/mbt/model/ccv_test.qnt +++ b/tests/mbt/model/ccv_test.qnt @@ -320,4 +320,61 @@ module ccv_test { ) res._2 == "Cannot start and stop a consumer at the same time" } + + // ===== Tests for Slashing ===== + // create a base state for the slashing tests. + // set consumer "receiver" to running and set a validator set with two validators as current + // and historical validator set on provider and consumer. + // Also, make it so the consumer state has received a vsc packet from the provider. + pure val validatorSet = Map( + "validator" -> 5, + "validator2" -> 5 + ) + pure val vscPacket = { + id: 0, + validatorSet: validatorSet, + sendingTime: 0, + timeoutTime: 1, + downtimeSlashAcks: List() + } + pure val SlashingTestState = + GetEmptyProtocolState.with( + "providerState", GetEmptyProtocolState.providerState.with( + "chainState", GetEmptyProtocolState.providerState.chainState.with( + "currentValidatorPowers", validatorSet + ).with( + "votingPowerHistory", List(validatorSet) + ) + ).with( + "consumerStatus", Map( + "receiver" -> RUNNING + ) + ) + ).with( + "consumerStates", GetEmptyProtocolState.consumerStates.put( + "receiver", GetEmptyConsumerState.with( + "chainState", GetEmptyProtocolState.providerState.chainState.with( + "currentValidatorPowers", validatorSet + ).with( + "votingPowerHistory", List(validatorSet) + ) + ).with( + "receivedVscPackets", List(vscPacket) + ) + ) + ) + + // ensure that sending a slash request for a double-sign infraction does not put outstandingDowntime in the state + run DoubleSignSlashRequestNoOutstandingDowntimeTest = + { + val result = SlashingTestState.sendSlashRequest( + "receiver", + "validator", + 0, + false + ) + not(result.hasError()) and + // should not have outstanding downtime, since the slash is for double-signing + result.newState.consumerStates.get("receiver").outstandingDowntime.size() == 0 + } } \ No newline at end of file