forked from bisq-network/bisq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle burning man selection height edge-cases
If trader A's block height is 134 his burning man selection height is 120, and if trader B's block height is 135 his burning man selection height is 130. The current burning man selection height verification code doesn't handle these edge-cases.
- Loading branch information
Showing
4 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
.../core/trade/protocol/bisq_v1/tasks/maker/MakerProcessesInputsForDepositTxRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package bisq.core.trade.protocol.bisq_v1.tasks.maker; | ||
|
||
import bisq.core.dao.burningman.DelayedPayoutTxReceiverService; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class MakerProcessesInputsForDepositTxRequestTest { | ||
private static final int GENESIS_HEIGHT = 102; | ||
private static final int GRID_SIZE = DelayedPayoutTxReceiverService.SNAPSHOT_SELECTION_GRID_SIZE; | ||
|
||
@Test | ||
void burningManSelectionHeightSameBlock() { | ||
assertEquals(130, | ||
DelayedPayoutTxReceiverService.getSnapshotHeight(GENESIS_HEIGHT, 139, GRID_SIZE, 0)); | ||
boolean isValid = MakerProcessesInputsForDepositTxRequest | ||
.verifyBurningManSelectionHeight(130, 130); | ||
assertTrue(isValid); | ||
} | ||
|
||
@Test | ||
void burningManSelectionHeightMakerOneBlockInFuture() { | ||
assertEquals(120, | ||
DelayedPayoutTxReceiverService.getSnapshotHeight(GENESIS_HEIGHT, 134, GRID_SIZE, 0)); | ||
assertEquals(130, | ||
DelayedPayoutTxReceiverService.getSnapshotHeight(GENESIS_HEIGHT, 135, GRID_SIZE, 0)); | ||
boolean isValid = MakerProcessesInputsForDepositTxRequest | ||
.verifyBurningManSelectionHeight(120, 130); | ||
assertTrue(isValid); | ||
} | ||
|
||
@Test | ||
void burningManSelectionHeightTakerOneBlockInFuture() { | ||
assertEquals(120, | ||
DelayedPayoutTxReceiverService.getSnapshotHeight(GENESIS_HEIGHT, 134, GRID_SIZE, 0)); | ||
assertEquals(130, | ||
DelayedPayoutTxReceiverService.getSnapshotHeight(GENESIS_HEIGHT, 135, GRID_SIZE, 0)); | ||
boolean isValid = MakerProcessesInputsForDepositTxRequest | ||
.verifyBurningManSelectionHeight(130, 120); | ||
assertTrue(isValid); | ||
} | ||
} |