Skip to content

Commit

Permalink
chore: refactor buffer types in foundry tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shotaronowhere committed Mar 18, 2024
1 parent aad9450 commit b95f82b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
8 changes: 4 additions & 4 deletions test/foundry/BridgeCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ contract BridgeCreatorTest is Test {
30,
40
);
DelayBuffer.BufferConfig memory bufferConfig = DelayBuffer.BufferConfig({
BufferConfig memory bufferConfig = BufferConfig({
thresholdSeconds: type(uint64).max,
thresholdBlocks: type(uint64).max,
maxBufferSeconds: 0,
maxBufferBlocks: 0,
replenishRate: DelayBuffer.ReplenishRate({
replenishRate: ReplenishRate({
secondsPerPeriod: 0,
blocksPerPeriod: 0,
periodSeconds: 0,
Expand Down Expand Up @@ -220,12 +220,12 @@ contract BridgeCreatorTest is Test {
30,
40
);
DelayBuffer.BufferConfig memory bufferConfig = DelayBuffer.BufferConfig({
BufferConfig memory bufferConfig = BufferConfig({
thresholdSeconds: type(uint64).max,
thresholdBlocks: type(uint64).max,
maxBufferSeconds: 0,
maxBufferBlocks: 0,
replenishRate: DelayBuffer.ReplenishRate({
replenishRate: ReplenishRate({
secondsPerPeriod: 0,
blocksPerPeriod: 0,
periodSeconds: 0,
Expand Down
28 changes: 14 additions & 14 deletions test/foundry/DelayBuffer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ contract DelayBufferableTest is Test {
uint64 constant period = 30;
uint64 constant threshold = 5;

DelayBuffer.BufferConfig config = DelayBuffer.BufferConfig({
BufferConfig config = BufferConfig({
thresholdBlocks: 5,
thresholdSeconds: 5,
maxBufferBlocks: 1000,
maxBufferSeconds: 1000,
replenishRate: DelayBuffer.ReplenishRate({
replenishRate: ReplenishRate({
blocksPerPeriod: 100,
periodBlocks: 30,
secondsPerPeriod: 100,
Expand All @@ -32,28 +32,28 @@ contract DelayBufferableTest is Test {
delaySeconds: 24 * 60 * 60,
futureSeconds: 32 * 2 * 12
});
DelayBuffer.BufferConfig configBufferable = DelayBuffer.BufferConfig({
BufferConfig configBufferable = BufferConfig({
thresholdBlocks: 60 * 60 * 2 / 12,
thresholdSeconds: 60 * 60 * 2,
maxBufferBlocks: 24 * 60 * 60 / 12 * 2,
maxBufferSeconds: 24 * 60 * 60 * 2,
replenishRate: DelayBuffer.ReplenishRate({
replenishRate: ReplenishRate({
secondsPerPeriod: 1,
blocksPerPeriod: 1,
periodSeconds: 14,
periodBlocks: 14
})
});
using DelayBuffer for DelayBuffer.BufferData;
DelayBuffer.BufferData delayBuffer;
DelayBuffer.BufferData delayBufferDefault = DelayBuffer.BufferData({
using DelayBuffer for BufferData;
BufferData delayBuffer;
BufferData delayBufferDefault = BufferData({
bufferBlocks: configBufferable.maxBufferBlocks,
bufferSeconds: configBufferable.maxBufferSeconds,
syncExpiryBlockNumber: 0,
syncExpiryTimestamp: 0,
roundOffBlocks: 0,
roundOffSeconds: 0,
prevDelay: DelayBuffer.DelayHistory({
prevDelay: DelayHistory({
blockNumber: 0,
timestamp: 0,
delayBlocks: 0,
Expand Down Expand Up @@ -148,14 +148,14 @@ contract DelayBufferableTest is Test {
}

function testUpdateBuffers() public {
delayBuffer = DelayBuffer.BufferData({
delayBuffer = BufferData({
bufferBlocks: 10,
bufferSeconds: 10,
syncExpiryBlockNumber: 0,
syncExpiryTimestamp: 0,
roundOffBlocks: 10,
roundOffSeconds: 10,
prevDelay: DelayBuffer.DelayHistory({
prevDelay: DelayHistory({
blockNumber: 10,
timestamp: 10,
delayBlocks: 10,
Expand All @@ -176,14 +176,14 @@ contract DelayBufferableTest is Test {
assertEq(delayBuffer.prevDelay.timestamp, 20);
assertEq(delayBuffer.prevDelay.delaySeconds, 5);

delayBuffer = DelayBuffer.BufferData({
delayBuffer = BufferData({
bufferBlocks: 10,
bufferSeconds: 10,
syncExpiryBlockNumber: 0,
syncExpiryTimestamp: 0,
roundOffBlocks: 10,
roundOffSeconds: 10,
prevDelay: DelayBuffer.DelayHistory({
prevDelay: DelayHistory({
blockNumber: 10,
timestamp: 10,
delayBlocks: 3,
Expand All @@ -208,14 +208,14 @@ contract DelayBufferableTest is Test {
}

function testPendingDelay() public {
delayBuffer = DelayBuffer.BufferData({
delayBuffer = BufferData({
bufferBlocks: 10,
bufferSeconds: 10,
syncExpiryBlockNumber: 0,
syncExpiryTimestamp: 0,
roundOffBlocks: 10,
roundOffSeconds: 10,
prevDelay: DelayBuffer.DelayHistory({
prevDelay: DelayHistory({
blockNumber: 10,
timestamp: 10,
delayBlocks: 10,
Expand Down
12 changes: 6 additions & 6 deletions test/foundry/RollupCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ contract RollupCreatorTest is Test {
60 * 60 * 24,
60 * 60
);
DelayBuffer.BufferConfig memory bufferConfig = DelayBuffer.BufferConfig({
BufferConfig memory bufferConfig = BufferConfig({
thresholdSeconds: type(uint64).max,
thresholdBlocks: type(uint64).max,
maxBufferSeconds: 0,
maxBufferBlocks: 0,
replenishRate: DelayBuffer.ReplenishRate({
replenishRate: ReplenishRate({
secondsPerPeriod: 0,
blocksPerPeriod: 0,
periodSeconds: 0,
Expand Down Expand Up @@ -282,12 +282,12 @@ contract RollupCreatorTest is Test {
60 * 60 * 24,
60 * 60
);
DelayBuffer.BufferConfig memory bufferConfig = DelayBuffer.BufferConfig({
BufferConfig memory bufferConfig = BufferConfig({
thresholdSeconds: type(uint64).max,
thresholdBlocks: type(uint64).max,
maxBufferSeconds: 0,
maxBufferBlocks: 0,
replenishRate: DelayBuffer.ReplenishRate({
replenishRate: ReplenishRate({
secondsPerPeriod: 0,
blocksPerPeriod: 0,
periodSeconds: 0,
Expand Down Expand Up @@ -451,12 +451,12 @@ contract RollupCreatorTest is Test {
60 * 60 * 24,
60 * 60
);
DelayBuffer.BufferConfig memory bufferConfig = DelayBuffer.BufferConfig({
BufferConfig memory bufferConfig = BufferConfig({
thresholdSeconds: type(uint64).max,
thresholdBlocks: type(uint64).max,
maxBufferSeconds: 0,
maxBufferBlocks: 0,
replenishRate: DelayBuffer.ReplenishRate({
replenishRate: ReplenishRate({
secondsPerPeriod: 0,
blocksPerPeriod: 0,
periodSeconds: 0,
Expand Down
Loading

0 comments on commit b95f82b

Please sign in to comment.