@@ -12,13 +12,13 @@ import {LineraToken} from "../LineraToken.sol";
1212// ------------------------------------------------------------------
1313
1414bytes32 constant CHAIN_ID = bytes32 (uint256 (0xC1 ));
15- uint64 constant HEIGHT = 42 ;
16- uint32 constant TX = 0 ;
17- uint128 constant AMOUNT = 1_000_000_000_000_000_000 ; // 1e18
18- address constant RECIP_0 = address (0xA0 );
19- address constant RECIP_1 = address (0xA1 );
20- address constant RECIP_2 = address (0xA2 );
21- bytes32 constant APP_ID = bytes32 (uint256 (0xF00D ));
15+ uint64 constant HEIGHT = 42 ;
16+ uint32 constant TX = 0 ;
17+ uint128 constant AMOUNT = 1_000_000_000_000_000_000 ; // 1e18
18+ address constant RECIP_0 = address (0xA0 );
19+ address constant RECIP_1 = address (0xA1 );
20+ address constant RECIP_2 = address (0xA2 );
21+ bytes32 constant APP_ID = bytes32 (uint256 (0xF00D ));
2222
2323// ------------------------------------------------------------------
2424// MockLightClientForBurns
@@ -29,38 +29,34 @@ bytes32 constant APP_ID = bytes32(uint256(0xF00D));
2929// ------------------------------------------------------------------
3030contract MockLightClientForBurns {
3131 bytes32 public immutable chainIdRet;
32- uint64 public immutable heightRet;
33- uint32 public immutable txIndexUsed;
32+ uint64 public immutable heightRet;
33+ uint32 public immutable txIndexUsed;
3434 bytes32 public immutable fungibleAppIdRet;
35- uint32 public immutable numBurns;
35+ uint32 public immutable numBurns;
3636 uint128 public immutable amountPerBurn;
3737 address public immutable recipBase;
3838
3939 constructor (
4040 bytes32 _chainId ,
41- uint64 _height ,
42- uint32 _txIndex ,
41+ uint64 _height ,
42+ uint32 _txIndex ,
4343 bytes32 _fungibleAppId ,
44- uint32 _numBurns ,
44+ uint32 _numBurns ,
4545 uint128 _amountPerBurn ,
4646 address _recipBase
4747 ) {
48- chainIdRet = _chainId;
49- heightRet = _height;
50- txIndexUsed = _txIndex;
48+ chainIdRet = _chainId;
49+ heightRet = _height;
50+ txIndexUsed = _txIndex;
5151 fungibleAppIdRet = _fungibleAppId;
52- numBurns = _numBurns;
53- amountPerBurn = _amountPerBurn;
54- recipBase = _recipBase;
52+ numBurns = _numBurns;
53+ amountPerBurn = _amountPerBurn;
54+ recipBase = _recipBase;
5555 }
5656
57- function verifyBlock (bytes calldata )
58- external
59- view
60- returns (BridgeTypes.Block memory b , bytes32 sigHash )
61- {
57+ function verifyBlock (bytes calldata ) external view returns (BridgeTypes.Block memory b , bytes32 sigHash ) {
6258 b.header.chain_id.value.value = chainIdRet;
63- b.header.height.value = heightRet;
59+ b.header.height.value = heightRet;
6460
6561 // Allocate txIndexUsed + 1 tx-slots; all before txIndexUsed are empty.
6662 b.body.events = new BridgeTypes.Event [][](uint256 (txIndexUsed) + 1 );
@@ -95,32 +91,22 @@ contract MockLightClientForBurns {
9591// ------------------------------------------------------------------
9692contract MockLightClientForNonBurn {
9793 bytes32 public immutable chainIdRet;
98- uint64 public immutable heightRet;
94+ uint64 public immutable heightRet;
9995 bytes32 public immutable fungibleAppIdRet;
10096 uint128 public immutable amountPerBurn;
10197 address public immutable recipBase;
10298
103- constructor (
104- bytes32 _chainId ,
105- uint64 _height ,
106- bytes32 _fungibleAppId ,
107- uint128 _amountPerBurn ,
108- address _recipBase
109- ) {
110- chainIdRet = _chainId;
111- heightRet = _height;
99+ constructor (bytes32 _chainId , uint64 _height , bytes32 _fungibleAppId , uint128 _amountPerBurn , address _recipBase ) {
100+ chainIdRet = _chainId;
101+ heightRet = _height;
112102 fungibleAppIdRet = _fungibleAppId;
113- amountPerBurn = _amountPerBurn;
114- recipBase = _recipBase;
103+ amountPerBurn = _amountPerBurn;
104+ recipBase = _recipBase;
115105 }
116106
117- function verifyBlock (bytes calldata )
118- external
119- view
120- returns (BridgeTypes.Block memory b , bytes32 sigHash )
121- {
107+ function verifyBlock (bytes calldata ) external view returns (BridgeTypes.Block memory b , bytes32 sigHash ) {
122108 b.header.chain_id.value.value = chainIdRet;
123- b.header.height.value = heightRet;
109+ b.header.height.value = heightRet;
124110
125111 b.body.events = new BridgeTypes.Event [][](1 );
126112 b.body.events[0 ] = new BridgeTypes.Event [](1 );
@@ -165,11 +151,8 @@ function _u32s_single(uint32 a) pure returns (uint32[] memory) {
165151contract FungibleBridgeProcessBurnsTest is Test {
166152 // Deploy a bridge backed by `lc`, with a LineraToken that has
167153 // `supply` tokens pre-minted to the bridge.
168- function _deployBridge (address lc , uint256 supply )
169- internal
170- returns (FungibleBridge bridge , LineraToken tok )
171- {
172- tok = new LineraToken ("Test " , "TST " , supply);
154+ function _deployBridge (address lc , uint256 supply ) internal returns (FungibleBridge bridge , LineraToken tok ) {
155+ tok = new LineraToken ("Test " , "TST " , supply);
173156 bridge = new FungibleBridge (lc, CHAIN_ID, address (tok), APP_ID);
174157 // Send all tokens to the bridge so transfer() calls succeed.
175158 tok.transfer (address (bridge), supply);
@@ -180,20 +163,18 @@ contract FungibleBridgeProcessBurnsTest is Test {
180163 function test_processBurns_single_position_marks_processed () public {
181164 // 2 burns in tx TX at positions 0 and 1 with stream indices 5 and 6.
182165 // Settle only position 0; assert (HEIGHT, 5) is flipped, (HEIGHT, 6) stays false.
183- MockLightClientForBurns lc =
184- new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 2 , AMOUNT, RECIP_0);
166+ MockLightClientForBurns lc = new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 2 , AMOUNT, RECIP_0);
185167 (FungibleBridge bridge ,) = _deployBridge (address (lc), AMOUNT * 10 );
186168
187169 bridge.processBurns (hex "deadbeef " , TX, _u32s_single (0 ));
188170
189- assertTrue ( bridge.isBurnProcessed (HEIGHT, 5 ), "stream index 5 should be processed " );
171+ assertTrue (bridge.isBurnProcessed (HEIGHT, 5 ), "stream index 5 should be processed " );
190172 assertFalse (bridge.isBurnProcessed (HEIGHT, 6 ), "stream index 6 should not be processed yet " );
191173 }
192174
193175 function test_processBurns_multi_position_marks_both_processed () public {
194176 // 2 burns; settle both positions; both flags true.
195- MockLightClientForBurns lc =
196- new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 2 , AMOUNT, RECIP_0);
177+ MockLightClientForBurns lc = new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 2 , AMOUNT, RECIP_0);
197178 (FungibleBridge bridge ,) = _deployBridge (address (lc), AMOUNT * 10 );
198179
199180 bridge.processBurns (hex "deadbeef " , TX, _u32s (0 , 1 ));
@@ -204,8 +185,7 @@ contract FungibleBridgeProcessBurnsTest is Test {
204185
205186 function test_processBurns_already_processed_reverts () public {
206187 // 1 burn; settle; settle again → revert "burn already processed".
207- MockLightClientForBurns lc =
208- new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 1 , AMOUNT, RECIP_0);
188+ MockLightClientForBurns lc = new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 1 , AMOUNT, RECIP_0);
209189 (FungibleBridge bridge ,) = _deployBridge (address (lc), AMOUNT * 10 );
210190
211191 bridge.processBurns (hex "deadbeef " , TX, _u32s_single (0 ));
@@ -216,8 +196,7 @@ contract FungibleBridgeProcessBurnsTest is Test {
216196
217197 function test_processBurns_tx_index_out_of_range_reverts () public {
218198 // Block has 1 tx; processBurns with txIndex=99 → revert "txIndex out of range".
219- MockLightClientForBurns lc =
220- new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 1 , AMOUNT, RECIP_0);
199+ MockLightClientForBurns lc = new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 1 , AMOUNT, RECIP_0);
221200 (FungibleBridge bridge ,) = _deployBridge (address (lc), AMOUNT * 10 );
222201
223202 vm.expectRevert (bytes ("txIndex out of range " ));
@@ -226,8 +205,7 @@ contract FungibleBridgeProcessBurnsTest is Test {
226205
227206 function test_processBurns_event_pos_out_of_range_reverts () public {
228207 // 2 burns at positions 0,1; processBurns with position=99 → revert "eventPos out of range".
229- MockLightClientForBurns lc =
230- new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 2 , AMOUNT, RECIP_0);
208+ MockLightClientForBurns lc = new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 2 , AMOUNT, RECIP_0);
231209 (FungibleBridge bridge ,) = _deployBridge (address (lc), AMOUNT * 10 );
232210
233211 vm.expectRevert (bytes ("eventPos out of range " ));
@@ -237,8 +215,7 @@ contract FungibleBridgeProcessBurnsTest is Test {
237215 function test_processBurns_non_burn_event_reverts () public {
238216 // MockLightClient returns a Block whose only event has the wrong
239217 // stream_name ("deposits") → processBurns(tx=0, [0]) → revert "not a matching burn".
240- MockLightClientForNonBurn lc =
241- new MockLightClientForNonBurn (CHAIN_ID, HEIGHT, APP_ID, AMOUNT, RECIP_0);
218+ MockLightClientForNonBurn lc = new MockLightClientForNonBurn (CHAIN_ID, HEIGHT, APP_ID, AMOUNT, RECIP_0);
242219 (FungibleBridge bridge ,) = _deployBridge (address (lc), AMOUNT * 10 );
243220
244221 vm.expectRevert (bytes ("not a matching burn " ));
@@ -250,8 +227,7 @@ contract FungibleBridgeProcessBurnsTest is Test {
250227 // Step 1: settle position 1 alone (succeeds).
251228 // Step 2: settle [0, 1] → reverts on position 1 ("burn already processed").
252229 // Assert (HEIGHT, stream-index-of-pos-0) is STILL false (revert rolled back pos-0 update).
253- MockLightClientForBurns lc =
254- new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 2 , AMOUNT, RECIP_0);
230+ MockLightClientForBurns lc = new MockLightClientForBurns (CHAIN_ID, HEIGHT, TX, APP_ID, 2 , AMOUNT, RECIP_0);
255231 (FungibleBridge bridge ,) = _deployBridge (address (lc), AMOUNT * 10 );
256232
257233 // Settle position 1 (stream index 6).
0 commit comments