-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinternal-claims.bats
More file actions
1745 lines (1572 loc) Β· 87.1 KB
/
internal-claims.bats
File metadata and controls
1745 lines (1572 loc) Β· 87.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bats
# bats file_tags=aggkit
# shellcheck disable=SC2154,SC2034
setup() {
load '../../core/helpers/agglayer-cdk-common-setup'
_agglayer_cdk_common_setup
readonly internal_claims_artifact_path="$PROJECT_ROOT/core/contracts/bridgeAsset/InternalClaims.json"
# Deploy the InternalClaims contract once for all tests
log "π§ Deploying InternalClaims contract for all tests"
# Get bytecode from the contract artifact
local bytecode
bytecode=$(jq -r '.bytecode.object // .bytecode' "$internal_claims_artifact_path")
if [[ -z "$bytecode" || "$bytecode" == "null" ]]; then
log "β Error: Failed to read bytecode from $internal_claims_artifact_path"
exit 1
fi
# ABI-encode the constructor argument (bridge address)
local encoded_args
encoded_args=$(cast abi-encode "constructor(address)" "$l2_bridge_addr")
if [[ -z "$encoded_args" ]]; then
log "β Failed to ABI-encode constructor argument"
exit 1
fi
# Concatenate bytecode and encoded constructor args
local deploy_bytecode="${bytecode}${encoded_args:2}" # Remove 0x from encoded args
# Deploy the contract
local deploy_output
deploy_output=$(cast send --rpc-url "$L2_RPC_URL" \
--private-key "$sender_private_key" \
--create "$deploy_bytecode" 2>&1)
if [[ $? -ne 0 ]]; then
log "β Error: Failed to deploy contract"
log "$deploy_output"
exit 1
fi
# Extract contract address from output
internal_claim_sc_addr=$(echo "$deploy_output" | grep -o 'contractAddress\s\+\(0x[a-fA-F0-9]\{40\}\)' | awk '{print $2}')
if [[ -z "$internal_claim_sc_addr" ]]; then
log "β Failed to extract deployed contract address"
log "$deploy_output"
exit 1
fi
readonly internal_claim_sc_addr
log "β
InternalClaims contract deployed at: $internal_claim_sc_addr"
}
@test "Test triple claim internal calls -> 3 success" {
# STEP 1: Bridge first asset and get all claim parameters
# ========================================
log "π STEP 1: Bridging first asset from L1 to L2"
destination_addr=$sender_addr
destination_net=$l2_rpc_network_id
# Bridge first asset using the helper function
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_1=$output
log "π First bridge asset transaction hash: $bridge_tx_hash_1"
# Extract claim parameters for first asset
local claim_params_1
claim_params_1=$(extract_claim_parameters_json "$bridge_tx_hash_1" "first" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_1
proof_local_exit_root_1=$(echo "$claim_params_1" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_1
proof_rollup_exit_root_1=$(echo "$claim_params_1" | jq -r '.proof_rollup_exit_root')
local global_index_1
global_index_1=$(echo "$claim_params_1" | jq -r '.global_index')
local mainnet_exit_root_1
mainnet_exit_root_1=$(echo "$claim_params_1" | jq -r '.mainnet_exit_root')
local rollup_exit_root_1
rollup_exit_root_1=$(echo "$claim_params_1" | jq -r '.rollup_exit_root')
local origin_network_1
origin_network_1=$(echo "$claim_params_1" | jq -r '.origin_network')
local origin_address_1
origin_address_1=$(echo "$claim_params_1" | jq -r '.origin_address')
local destination_network_1
destination_network_1=$(echo "$claim_params_1" | jq -r '.destination_network')
local destination_address_1
destination_address_1=$(echo "$claim_params_1" | jq -r '.destination_address')
local amount_1
amount_1=$(echo "$claim_params_1" | jq -r '.amount')
local metadata_1
metadata_1=$(echo "$claim_params_1" | jq -r '.metadata')
log "β
First asset claim parameters extracted successfully"
# ========================================
# STEP 2: Bridge second asset and get all claim parameters
# ========================================
log "π STEP 2: Bridging second asset from L1 to L2"
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_2=$output
log "π Second bridge asset transaction hash: $bridge_tx_hash_2"
# Extract claim parameters for second asset
local claim_params_2
claim_params_2=$(extract_claim_parameters_json "$bridge_tx_hash_2" "second" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_2
proof_local_exit_root_2=$(echo "$claim_params_2" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_2
proof_rollup_exit_root_2=$(echo "$claim_params_2" | jq -r '.proof_rollup_exit_root')
local global_index_2
global_index_2=$(echo "$claim_params_2" | jq -r '.global_index')
local mainnet_exit_root_2
mainnet_exit_root_2=$(echo "$claim_params_2" | jq -r '.mainnet_exit_root')
local rollup_exit_root_2
rollup_exit_root_2=$(echo "$claim_params_2" | jq -r '.rollup_exit_root')
local origin_network_2
origin_network_2=$(echo "$claim_params_2" | jq -r '.origin_network')
local origin_address_2
origin_address_2=$(echo "$claim_params_2" | jq -r '.origin_address')
local destination_network_2
destination_network_2=$(echo "$claim_params_2" | jq -r '.destination_network')
local destination_address_2
destination_address_2=$(echo "$claim_params_2" | jq -r '.destination_address')
local amount_2
amount_2=$(echo "$claim_params_2" | jq -r '.amount')
local metadata_2
metadata_2=$(echo "$claim_params_2" | jq -r '.metadata')
log "β
Second asset claim parameters extracted successfully"
# ========================================
# STEP 3: Bridge third asset and get all claim parameters
# ========================================
log "π STEP 3: Bridging third asset from L1 to L2"
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_3=$output
log "π Third bridge asset transaction hash: $bridge_tx_hash_3"
# Extract claim parameters for third asset
local claim_params_3
claim_params_3=$(extract_claim_parameters_json "$bridge_tx_hash_3" "third" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_3
proof_local_exit_root_3=$(echo "$claim_params_3" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_3
proof_rollup_exit_root_3=$(echo "$claim_params_3" | jq -r '.proof_rollup_exit_root')
local global_index_3
global_index_3=$(echo "$claim_params_3" | jq -r '.global_index')
local mainnet_exit_root_3
mainnet_exit_root_3=$(echo "$claim_params_3" | jq -r '.mainnet_exit_root')
local rollup_exit_root_3
rollup_exit_root_3=$(echo "$claim_params_3" | jq -r '.rollup_exit_root')
local origin_network_3
origin_network_3=$(echo "$claim_params_3" | jq -r '.origin_network')
local origin_address_3
origin_address_3=$(echo "$claim_params_3" | jq -r '.origin_address')
local destination_network_3
destination_network_3=$(echo "$claim_params_3" | jq -r '.destination_network')
local destination_address_3
destination_address_3=$(echo "$claim_params_3" | jq -r '.destination_address')
local amount_3
amount_3=$(echo "$claim_params_3" | jq -r '.amount')
local metadata_3
metadata_3=$(echo "$claim_params_3" | jq -r '.metadata')
log "β
Third asset claim parameters extracted successfully"
# ========================================
# STEP 4: Bridge fourth asset
# ========================================
log "π STEP 4: Bridging fourth asset from L1 to L2"
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_4=$output
log "π Fourth bridge asset transaction hash: $bridge_tx_hash_4"
# Extract claim parameters for fourth asset
local claim_params_4
claim_params_4=$(extract_claim_parameters_json "$bridge_tx_hash_4" "fourth" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_4
proof_local_exit_root_4=$(echo "$claim_params_4" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_4
proof_rollup_exit_root_4=$(echo "$claim_params_4" | jq -r '.proof_rollup_exit_root')
local global_index_4
global_index_4=$(echo "$claim_params_4" | jq -r '.global_index')
local mainnet_exit_root_4
mainnet_exit_root_4=$(echo "$claim_params_4" | jq -r '.mainnet_exit_root')
local rollup_exit_root_4
rollup_exit_root_4=$(echo "$claim_params_4" | jq -r '.rollup_exit_root')
local origin_network_4
origin_network_4=$(echo "$claim_params_4" | jq -r '.origin_network')
local origin_address_4
origin_address_4=$(echo "$claim_params_4" | jq -r '.origin_address')
local destination_network_4
destination_network_4=$(echo "$claim_params_4" | jq -r '.destination_network')
local destination_address_4
destination_address_4=$(echo "$claim_params_4" | jq -r '.destination_address')
local amount_4
amount_4=$(echo "$claim_params_4" | jq -r '.amount')
local metadata_4
metadata_4=$(echo "$claim_params_4" | jq -r '.metadata')
log "β
Fourth asset claim parameters extracted successfully"
# ========================================
# STEP 5: Update contract with all four sets of claim parameters
# ========================================
log "βοΈ STEP 5: Updating contract parameters with all four sets of claim data"
local update_output
update_output=$(cast send \
"$internal_claim_sc_addr" \
"updateParameters(bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes,bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes,bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes,bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes)" \
"$proof_local_exit_root_1" \
"$proof_rollup_exit_root_1" \
"$global_index_1" \
"$mainnet_exit_root_1" \
"$rollup_exit_root_1" \
"$origin_network_1" \
"$origin_address_1" \
"$destination_network_1" \
"$destination_address_1" \
"$amount_1" \
"$metadata_1" \
"$proof_local_exit_root_2" \
"$proof_rollup_exit_root_2" \
"$global_index_2" \
"$mainnet_exit_root_2" \
"$rollup_exit_root_2" \
"$origin_network_2" \
"$origin_address_2" \
"$destination_network_2" \
"$destination_address_2" \
"$amount_2" \
"$metadata_2" \
"$proof_local_exit_root_3" \
"$proof_rollup_exit_root_3" \
"$global_index_3" \
"$mainnet_exit_root_3" \
"$rollup_exit_root_3" \
"$origin_network_3" \
"$origin_address_3" \
"$destination_network_3" \
"$destination_address_3" \
"$amount_3" \
"$metadata_3" \
"$proof_local_exit_root_4" \
"$proof_rollup_exit_root_4" \
"$global_index_4" \
"$mainnet_exit_root_4" \
"$rollup_exit_root_4" \
"$origin_network_4" \
"$origin_address_4" \
"$destination_network_4" \
"$destination_address_4" \
"$amount_4" \
"$metadata_4" \
--rpc-url "$L2_RPC_URL" \
--private-key "$sender_private_key" 2>&1)
if [[ $? -ne 0 ]]; then
log "β Error: Failed to update parameters"
log "$update_output"
exit 1
fi
log "β
Contract parameters updated successfully with all four sets of claim data"
# ========================================
# STEP 6: Test onMessageReceived functionality
# ========================================
log "π§ͺ STEP 6: Testing onMessageReceived with valid parameters (will attempt all four asset claims)"
local on_message_output
on_message_output=$(cast send \
"$internal_claim_sc_addr" \
"onMessageReceived(address,uint32,bytes)" \
"$origin_address_1" \
"$origin_network_1" \
"0x" \
--rpc-url "$L2_RPC_URL" \
--private-key "$sender_private_key" 2>&1)
log "π onMessageReceived output: $on_message_output"
# Check if the transaction was successful
if [[ $? -eq 0 ]]; then
local tx_hash
tx_hash=$(echo "$on_message_output" | grep -o '0x[a-fA-F0-9]*')
log "β
onMessageReceived transaction successful: $tx_hash"
# Validate the bridge service get claims API to verify all claims were processed
log "π Validating first asset claim was processed"
log "Global index: $global_index_1"
run get_claim "$l2_rpc_network_id" "$global_index_1" 50 10 "$aggkit_bridge_url"
assert_success
local claim_1="$output"
log "π First claim response: $claim_1"
# Validate all parameters for first claim
log "π Validating all parameters for first claim"
local claim_1_mainnet_exit_root
claim_1_mainnet_exit_root=$(echo "$claim_1" | jq -r '.mainnet_exit_root')
local claim_1_rollup_exit_root
claim_1_rollup_exit_root=$(echo "$claim_1" | jq -r '.rollup_exit_root')
local claim_1_global_exit_root
claim_1_global_exit_root=$(echo "$claim_1" | jq -r '.global_exit_root')
local claim_1_origin_network
claim_1_origin_network=$(echo "$claim_1" | jq -r '.origin_network')
local claim_1_origin_address
claim_1_origin_address=$(echo "$claim_1" | jq -r '.origin_address')
local claim_1_destination_network
claim_1_destination_network=$(echo "$claim_1" | jq -r '.destination_network')
local claim_1_destination_address
claim_1_destination_address=$(echo "$claim_1" | jq -r '.destination_address')
local claim_1_amount
claim_1_amount=$(echo "$claim_1" | jq -r '.amount')
local claim_1_metadata
claim_1_metadata=$(echo "$claim_1" | jq -r '.metadata')
log "π³ First claim mainnet exit root: $claim_1_mainnet_exit_root (Expected: $mainnet_exit_root_1)"
log "π³ First claim rollup exit root: $claim_1_rollup_exit_root (Expected: $rollup_exit_root_1)"
log "π³ First claim global exit root: $claim_1_global_exit_root"
log "π First claim origin network: $claim_1_origin_network (Expected: $origin_network_1)"
log "π First claim origin address: $claim_1_origin_address (Expected: $origin_address_1)"
log "π First claim destination network: $claim_1_destination_network (Expected: $destination_network_1)"
log "π First claim destination address: $claim_1_destination_address (Expected: $destination_address_1)"
log "π° First claim amount: $claim_1_amount (Expected: $amount_1)"
log "π First claim metadata: $claim_1_metadata (Expected: $metadata_1)"
# Verify all field values match expected values
assert_equal "$claim_1_mainnet_exit_root" "$mainnet_exit_root_1"
assert_equal "$claim_1_rollup_exit_root" "$rollup_exit_root_1"
assert_equal "$claim_1_origin_network" "$origin_network_1"
assert_equal "$claim_1_origin_address" "$origin_address_1"
assert_equal "$claim_1_destination_network" "$destination_network_1"
assert_equal "$claim_1_destination_address" "$destination_address_1"
assert_equal "$claim_1_amount" "$amount_1"
assert_equal "$claim_1_metadata" "$metadata_1"
# Validate proofs for first claim
log "π Validating proofs for first claim"
local claim_1_proof_local_exit_root
claim_1_proof_local_exit_root=$(echo "$claim_1" | jq -r '.proof_local_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
local claim_1_proof_rollup_exit_root
claim_1_proof_rollup_exit_root=$(echo "$claim_1" | jq -r '.proof_rollup_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
log "π First claim proof local exit root: $claim_1_proof_local_exit_root"
log "π Expected proof local exit root: $proof_local_exit_root_1"
log "π First claim proof rollup exit root: $claim_1_proof_rollup_exit_root"
log "π Expected proof rollup exit root: $proof_rollup_exit_root_1"
# Verify proof values match expected values
assert_equal "$claim_1_proof_local_exit_root" "$proof_local_exit_root_1"
assert_equal "$claim_1_proof_rollup_exit_root" "$proof_rollup_exit_root_1"
log "β
First claim proofs validated successfully"
log "β
First claim all fields validated successfully"
log "π Validating second asset claim was processed"
run get_claim "$l2_rpc_network_id" "$global_index_2" 50 10 "$aggkit_bridge_url"
assert_success
local claim_2="$output"
log "π Second claim response: $claim_2"
# Validate all parameters for second claim
log "π Validating all parameters for second claim"
local claim_2_mainnet_exit_root
claim_2_mainnet_exit_root=$(echo "$claim_2" | jq -r '.mainnet_exit_root')
local claim_2_rollup_exit_root
claim_2_rollup_exit_root=$(echo "$claim_2" | jq -r '.rollup_exit_root')
local claim_2_global_exit_root
claim_2_global_exit_root=$(echo "$claim_2" | jq -r '.global_exit_root')
local claim_2_origin_network
claim_2_origin_network=$(echo "$claim_2" | jq -r '.origin_network')
local claim_2_origin_address
claim_2_origin_address=$(echo "$claim_2" | jq -r '.origin_address')
local claim_2_destination_network
claim_2_destination_network=$(echo "$claim_2" | jq -r '.destination_network')
local claim_2_destination_address
claim_2_destination_address=$(echo "$claim_2" | jq -r '.destination_address')
local claim_2_amount
claim_2_amount=$(echo "$claim_2" | jq -r '.amount')
local claim_2_metadata
claim_2_metadata=$(echo "$claim_2" | jq -r '.metadata')
log "π³ Second claim mainnet exit root: $claim_2_mainnet_exit_root (Expected: $mainnet_exit_root_2)"
log "π³ Second claim rollup exit root: $claim_2_rollup_exit_root (Expected: $rollup_exit_root_2)"
log "π³ Second claim global exit root: $claim_2_global_exit_root"
log "π Second claim origin network: $claim_2_origin_network (Expected: $origin_network_2)"
log "π Second claim origin address: $claim_2_origin_address (Expected: $origin_address_2)"
log "π Second claim destination network: $claim_2_destination_network (Expected: $destination_network_2)"
log "π Second claim destination address: $claim_2_destination_address (Expected: $destination_address_2)"
log "π° Second claim amount: $claim_2_amount (Expected: $amount_2)"
log "π Second claim metadata: $claim_2_metadata (Expected: $metadata_2)"
# Verify all field values match expected values
assert_equal "$claim_2_mainnet_exit_root" "$mainnet_exit_root_2"
assert_equal "$claim_2_rollup_exit_root" "$rollup_exit_root_2"
assert_equal "$claim_2_origin_network" "$origin_network_2"
assert_equal "$claim_2_origin_address" "$origin_address_2"
assert_equal "$claim_2_destination_network" "$destination_network_2"
assert_equal "$claim_2_destination_address" "$destination_address_2"
assert_equal "$claim_2_amount" "$amount_2"
assert_equal "$claim_2_metadata" "$metadata_2"
# Validate proofs for second claim
log "π Validating proofs for second claim"
local claim_2_proof_local_exit_root
claim_2_proof_local_exit_root=$(echo "$claim_2" | jq -r '.proof_local_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
local claim_2_proof_rollup_exit_root
claim_2_proof_rollup_exit_root=$(echo "$claim_2" | jq -r '.proof_rollup_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
log "π Second claim proof local exit root: $claim_2_proof_local_exit_root"
log "π Expected proof local exit root: $proof_local_exit_root_2"
log "π Second claim proof rollup exit root: $claim_2_proof_rollup_exit_root"
log "π Expected proof rollup exit root: $proof_rollup_exit_root_2"
# Verify proof values match expected values
assert_equal "$claim_2_proof_local_exit_root" "$proof_local_exit_root_2"
assert_equal "$claim_2_proof_rollup_exit_root" "$proof_rollup_exit_root_2"
log "β
Second claim proofs validated successfully"
log "β
Second claim all fields validated successfully"
log "π Validating third asset claim was processed"
run get_claim "$l2_rpc_network_id" "$global_index_3" 50 10 "$aggkit_bridge_url"
assert_success
local claim_3="$output"
log "π Third claim response: $claim_3"
# Validate all parameters for third claim
log "π Validating all parameters for third claim"
local claim_3_mainnet_exit_root
claim_3_mainnet_exit_root=$(echo "$claim_3" | jq -r '.mainnet_exit_root')
local claim_3_rollup_exit_root
claim_3_rollup_exit_root=$(echo "$claim_3" | jq -r '.rollup_exit_root')
local claim_3_global_exit_root
claim_3_global_exit_root=$(echo "$claim_3" | jq -r '.global_exit_root')
local claim_3_origin_network
claim_3_origin_network=$(echo "$claim_3" | jq -r '.origin_network')
local claim_3_origin_address
claim_3_origin_address=$(echo "$claim_3" | jq -r '.origin_address')
local claim_3_destination_network
claim_3_destination_network=$(echo "$claim_3" | jq -r '.destination_network')
local claim_3_destination_address
claim_3_destination_address=$(echo "$claim_3" | jq -r '.destination_address')
local claim_3_amount
claim_3_amount=$(echo "$claim_3" | jq -r '.amount')
local claim_3_metadata
claim_3_metadata=$(echo "$claim_3" | jq -r '.metadata')
log "π³ Third claim mainnet exit root: $claim_3_mainnet_exit_root (Expected: $mainnet_exit_root_3)"
log "π³ Third claim rollup exit root: $claim_3_rollup_exit_root (Expected: $rollup_exit_root_3)"
log "π³ Third claim global exit root: $claim_3_global_exit_root"
log "π Third claim origin network: $claim_3_origin_network (Expected: $origin_network_3)"
log "π Third claim origin address: $claim_3_origin_address (Expected: $origin_address_3)"
log "π Third claim destination network: $claim_3_destination_network (Expected: $destination_network_3)"
log "π Third claim destination address: $claim_3_destination_address (Expected: $destination_address_3)"
log "π° Third claim amount: $claim_3_amount (Expected: $amount_3)"
log "π Third claim metadata: $claim_3_metadata (Expected: $metadata_3)"
# Verify all field values match expected values
assert_equal "$claim_3_mainnet_exit_root" "$mainnet_exit_root_3"
assert_equal "$claim_3_rollup_exit_root" "$rollup_exit_root_3"
assert_equal "$claim_3_origin_network" "$origin_network_3"
assert_equal "$claim_3_origin_address" "$origin_address_3"
assert_equal "$claim_3_destination_network" "$destination_network_3"
assert_equal "$claim_3_destination_address" "$destination_address_3"
assert_equal "$claim_3_amount" "$amount_3"
assert_equal "$claim_3_metadata" "$metadata_3"
# Validate proofs for third claim
log "π Validating proofs for third claim"
local claim_3_proof_local_exit_root
claim_3_proof_local_exit_root=$(echo "$claim_3" | jq -r '.proof_local_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
local claim_3_proof_rollup_exit_root
claim_3_proof_rollup_exit_root=$(echo "$claim_3" | jq -r '.proof_rollup_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
log "π Third claim proof local exit root: $claim_3_proof_local_exit_root"
log "π Expected proof local exit root: $proof_local_exit_root_3"
log "π Third claim proof rollup exit root: $claim_3_proof_rollup_exit_root"
log "π Expected proof rollup exit root: $proof_rollup_exit_root_3"
# Verify proof values match expected values
assert_equal "$claim_3_proof_local_exit_root" "$proof_local_exit_root_3"
assert_equal "$claim_3_proof_rollup_exit_root" "$proof_rollup_exit_root_3"
log "β
Third claim proofs validated successfully"
log "β
Third claim all fields validated successfully"
log "β
All four asset claims were successfully processed through onMessageReceived"
log "β
All parameters validated successfully for all four claims"
else
log "β onMessageReceived transaction failed"
log "$on_message_output"
exit 1
fi
log "π Test triple claim internal calls -> 3 success completed successfully"
log "π Summary:"
log " β
First asset bridge created and parameters extracted"
log " β
Second asset bridge created and parameters extracted"
log " β
Third asset bridge created and parameters extracted"
log " β
Fourth asset bridge created and parameters extracted"
log " β
All four sets of parameters configured in contract"
log " β
All asset claims processed successfully"
log " β
All parameters validated successfully for all claims"
}
@test "Test triple claim internal calls -> 1 success, 1 fail and 1 success" {
log "π§ͺ Testing triple claim internal calls: 1 success, 1 fail, 1 success"
# ========================================
# STEP 1: Bridge first asset and get all claim parameters
# ========================================
log "π STEP 1: Bridging first asset from L1 to L2"
destination_addr=$sender_addr
destination_net=$l2_rpc_network_id
# Bridge first asset using the helper function
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_1=$output
log "π First bridge asset transaction hash: $bridge_tx_hash_1"
# Extract claim parameters for first asset
local claim_params_1
claim_params_1=$(extract_claim_parameters_json "$bridge_tx_hash_1" "first" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_1
proof_local_exit_root_1=$(echo "$claim_params_1" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_1
proof_rollup_exit_root_1=$(echo "$claim_params_1" | jq -r '.proof_rollup_exit_root')
local global_index_1
global_index_1=$(echo "$claim_params_1" | jq -r '.global_index')
local mainnet_exit_root_1
mainnet_exit_root_1=$(echo "$claim_params_1" | jq -r '.mainnet_exit_root')
local rollup_exit_root_1
rollup_exit_root_1=$(echo "$claim_params_1" | jq -r '.rollup_exit_root')
local origin_network_1
origin_network_1=$(echo "$claim_params_1" | jq -r '.origin_network')
local origin_address_1
origin_address_1=$(echo "$claim_params_1" | jq -r '.origin_address')
local destination_network_1
destination_network_1=$(echo "$claim_params_1" | jq -r '.destination_network')
local destination_address_1
destination_address_1=$(echo "$claim_params_1" | jq -r '.destination_address')
local amount_1
amount_1=$(echo "$claim_params_1" | jq -r '.amount')
local metadata_1
metadata_1=$(echo "$claim_params_1" | jq -r '.metadata')
log "β
First asset claim parameters extracted successfully"
# ========================================
# STEP 2: Bridge second asset and get all claim parameters
# ========================================
log "π STEP 2: Bridging second asset from L1 to L2"
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_2=$output
log "π Second bridge asset transaction hash: $bridge_tx_hash_2"
# Extract claim parameters for second asset
local claim_params_2
claim_params_2=$(extract_claim_parameters_json "$bridge_tx_hash_2" "second" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_2
proof_local_exit_root_2=$(echo "$claim_params_2" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_2
proof_rollup_exit_root_2=$(echo "$claim_params_2" | jq -r '.proof_rollup_exit_root')
local global_index_2
global_index_2=$(echo "$claim_params_2" | jq -r '.global_index')
local mainnet_exit_root_2
mainnet_exit_root_2=$(echo "$claim_params_2" | jq -r '.mainnet_exit_root')
local rollup_exit_root_2
rollup_exit_root_2=$(echo "$claim_params_2" | jq -r '.rollup_exit_root')
local origin_network_2
origin_network_2=$(echo "$claim_params_2" | jq -r '.origin_network')
local origin_address_2
origin_address_2=$(echo "$claim_params_2" | jq -r '.origin_address')
local destination_network_2
destination_network_2=$(echo "$claim_params_2" | jq -r '.destination_network')
local destination_address_2
destination_address_2=$(echo "$claim_params_2" | jq -r '.destination_address')
local amount_2
amount_2=$(echo "$claim_params_2" | jq -r '.amount')
local metadata_2
metadata_2=$(echo "$claim_params_2" | jq -r '.metadata')
log "β
Second asset claim parameters extracted successfully"
# ========================================
# STEP 3: Bridge third asset and get all claim parameters
# ========================================
log "π STEP 3: Bridging third asset from L1 to L2"
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_3=$output
log "π Third bridge asset transaction hash: $bridge_tx_hash_3"
# Extract claim parameters for third asset
local claim_params_3
claim_params_3=$(extract_claim_parameters_json "$bridge_tx_hash_3" "third" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_3
proof_local_exit_root_3=$(echo "$claim_params_3" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_3
proof_rollup_exit_root_3=$(echo "$claim_params_3" | jq -r '.proof_rollup_exit_root')
local global_index_3
global_index_3=$(echo "$claim_params_3" | jq -r '.global_index')
local mainnet_exit_root_3
mainnet_exit_root_3=$(echo "$claim_params_3" | jq -r '.mainnet_exit_root')
local rollup_exit_root_3
rollup_exit_root_3=$(echo "$claim_params_3" | jq -r '.rollup_exit_root')
local origin_network_3
origin_network_3=$(echo "$claim_params_3" | jq -r '.origin_network')
local origin_address_3
origin_address_3=$(echo "$claim_params_3" | jq -r '.origin_address')
local destination_network_3
destination_network_3=$(echo "$claim_params_3" | jq -r '.destination_network')
local destination_address_3
destination_address_3=$(echo "$claim_params_3" | jq -r '.destination_address')
local amount_3
amount_3=$(echo "$claim_params_3" | jq -r '.amount')
local metadata_3
metadata_3=$(echo "$claim_params_3" | jq -r '.metadata')
log "β
Third asset claim parameters extracted successfully"
# ========================================
# STEP 4: Bridge fourth asset and get all claim parameters
# ========================================
log "π STEP 4: Bridging fourth asset from L1 to L2"
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_4=$output
log "π Fourth bridge asset transaction hash: $bridge_tx_hash_4"
# Extract claim parameters for fourth asset
local claim_params_4
claim_params_4=$(extract_claim_parameters_json "$bridge_tx_hash_4" "fourth" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_4
proof_local_exit_root_4=$(echo "$claim_params_4" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_4
proof_rollup_exit_root_4=$(echo "$claim_params_4" | jq -r '.proof_rollup_exit_root')
local global_index_4
global_index_4=$(echo "$claim_params_4" | jq -r '.global_index')
local mainnet_exit_root_4
mainnet_exit_root_4=$(echo "$claim_params_4" | jq -r '.mainnet_exit_root')
local rollup_exit_root_4
rollup_exit_root_4=$(echo "$claim_params_4" | jq -r '.rollup_exit_root')
local origin_network_4
origin_network_4=$(echo "$claim_params_4" | jq -r '.origin_network')
local origin_address_4
origin_address_4=$(echo "$claim_params_4" | jq -r '.origin_address')
local destination_network_4
destination_network_4=$(echo "$claim_params_4" | jq -r '.destination_network')
local destination_address_4
destination_address_4=$(echo "$claim_params_4" | jq -r '.destination_address')
local amount_4
amount_4=$(echo "$claim_params_4" | jq -r '.amount')
local metadata_4
metadata_4=$(echo "$claim_params_4" | jq -r '.metadata')
log "β
Fourth asset claim parameters extracted successfully"
# ========================================
# STEP 5: Create malformed parameters for second claim (to make it fail)
# ========================================
log "π§ STEP 5: Creating malformed parameters for second claim (to make it fail)"
# Create malformed proof for second claim
local malformed_proof_local_exit_root_2
malformed_proof_local_exit_root_2=$(echo "$proof_local_exit_root_2" | sed 's/0x[0-9a-fA-F]\{64\}/0xf077e0d22fd6721989347f053c33595697372ec8c0d0678b934bba193679e088/2')
local malformed_mainnet_exit_root_2=0x787bc577d07da1b6ca15c9b2c6d869e08a29663f498b65752604c75efee2cfe0
log "π§ Malformed proof for second claim: $malformed_proof_local_exit_root_2"
log "π§ Malformed mainnet exit root for second claim: $malformed_mainnet_exit_root_2"
# ========================================
# STEP 6: Update contract with all four sets of claim parameters
# ========================================
log "βοΈ STEP 6: Updating contract parameters with all four sets of claim data"
local update_output
update_output=$(cast send \
"$internal_claim_sc_addr" \
"updateParameters(bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes,bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes,bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes,bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes)" \
"$proof_local_exit_root_1" \
"$proof_rollup_exit_root_1" \
"$global_index_1" \
"$mainnet_exit_root_1" \
"$rollup_exit_root_1" \
"$origin_network_1" \
"$origin_address_1" \
"$destination_network_1" \
"$destination_address_1" \
"$amount_1" \
"$metadata_1" \
"$malformed_proof_local_exit_root_2" \
"$proof_rollup_exit_root_2" \
"$global_index_2" \
"$malformed_mainnet_exit_root_2" \
"$rollup_exit_root_2" \
"$origin_network_2" \
"$origin_address_2" \
"$destination_network_2" \
"$destination_address_2" \
"$amount_2" \
"$metadata_2" \
"$proof_local_exit_root_3" \
"$proof_rollup_exit_root_3" \
"$global_index_3" \
"$mainnet_exit_root_3" \
"$rollup_exit_root_3" \
"$origin_network_3" \
"$origin_address_3" \
"$destination_network_3" \
"$destination_address_3" \
"$amount_3" \
"$metadata_3" \
"$proof_local_exit_root_4" \
"$proof_rollup_exit_root_4" \
"$global_index_4" \
"$mainnet_exit_root_4" \
"$rollup_exit_root_4" \
"$origin_network_4" \
"$origin_address_4" \
"$destination_network_4" \
"$destination_address_4" \
"$amount_4" \
"$metadata_4" \
--rpc-url "$L2_RPC_URL" \
--private-key "$sender_private_key" 2>&1)
if [[ $? -ne 0 ]]; then
log "β Error: Failed to update parameters"
log "$update_output"
exit 1
fi
log "β
Contract parameters updated successfully with all four sets of claim data"
# ========================================
# STEP 7: Test onMessageReceived functionality
# ========================================
log "π§ͺ STEP 7: Testing onMessageReceived with valid parameters (will attempt all four asset claims)"
local on_message_output
on_message_output=$(cast send \
"$internal_claim_sc_addr" \
"onMessageReceived(address,uint32,bytes)" \
"$origin_address_1" \
"$origin_network_1" \
"0x" \
--rpc-url "$L2_RPC_URL" \
--private-key "$sender_private_key" 2>&1)
log "π onMessageReceived output: $on_message_output"
# Check if the transaction was successful (should succeed even if second claim fails)
if [[ $? -eq 0 ]]; then
local tx_hash
tx_hash=$(echo "$on_message_output" | grep -o '0x[a-fA-F0-9]*')
log "β
onMessageReceived transaction successful: $tx_hash"
log "π Validating first asset claim was processed"
log "Global index: $global_index_1"
run get_claim "$l2_rpc_network_id" "$global_index_1" 50 10 "$aggkit_bridge_url"
assert_success
local claim_1="$output"
log "π First claim response: $claim_1"
# Validate all parameters for first claim
log "π Validating all parameters for first claim"
local claim_1_mainnet_exit_root
claim_1_mainnet_exit_root=$(echo "$claim_1" | jq -r '.mainnet_exit_root')
local claim_1_rollup_exit_root
claim_1_rollup_exit_root=$(echo "$claim_1" | jq -r '.rollup_exit_root')
local claim_1_global_exit_root
claim_1_global_exit_root=$(echo "$claim_1" | jq -r '.global_exit_root')
local claim_1_origin_network
claim_1_origin_network=$(echo "$claim_1" | jq -r '.origin_network')
local claim_1_origin_address
claim_1_origin_address=$(echo "$claim_1" | jq -r '.origin_address')
local claim_1_destination_network
claim_1_destination_network=$(echo "$claim_1" | jq -r '.destination_network')
local claim_1_destination_address
claim_1_destination_address=$(echo "$claim_1" | jq -r '.destination_address')
local claim_1_amount
claim_1_amount=$(echo "$claim_1" | jq -r '.amount')
local claim_1_metadata
claim_1_metadata=$(echo "$claim_1" | jq -r '.metadata')
log "π³ First claim mainnet exit root: $claim_1_mainnet_exit_root (Expected: $mainnet_exit_root_1)"
log "π³ First claim rollup exit root: $claim_1_rollup_exit_root (Expected: $rollup_exit_root_1)"
log "π³ First claim global exit root: $claim_1_global_exit_root"
log "π First claim origin network: $claim_1_origin_network (Expected: $origin_network_1)"
log "π First claim origin address: $claim_1_origin_address (Expected: $origin_address_1)"
log "π First claim destination network: $claim_1_destination_network (Expected: $destination_network_1)"
log "π First claim destination address: $claim_1_destination_address (Expected: $destination_address_1)"
log "π° First claim amount: $claim_1_amount (Expected: $amount_1)"
log "π First claim metadata: $claim_1_metadata (Expected: $metadata_1)"
# Verify all field values match expected values
assert_equal "$claim_1_mainnet_exit_root" "$mainnet_exit_root_1"
assert_equal "$claim_1_rollup_exit_root" "$rollup_exit_root_1"
assert_equal "$claim_1_origin_network" "$origin_network_1"
assert_equal "$claim_1_origin_address" "$origin_address_1"
assert_equal "$claim_1_destination_network" "$destination_network_1"
assert_equal "$claim_1_destination_address" "$destination_address_1"
assert_equal "$claim_1_amount" "$amount_1"
assert_equal "$claim_1_metadata" "$metadata_1"
# Validate proofs for first claim
log "π Validating proofs for first claim"
local claim_1_proof_local_exit_root
claim_1_proof_local_exit_root=$(echo "$claim_1" | jq -r '.proof_local_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
local claim_1_proof_rollup_exit_root
claim_1_proof_rollup_exit_root=$(echo "$claim_1" | jq -r '.proof_rollup_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
log "π First claim proof local exit root: $claim_1_proof_local_exit_root"
log "π Expected proof local exit root: $proof_local_exit_root_1"
log "π First claim proof rollup exit root: $claim_1_proof_rollup_exit_root"
log "π Expected proof rollup exit root: $proof_rollup_exit_root_1"
# Verify proof values match expected values
assert_equal "$claim_1_proof_local_exit_root" "$proof_local_exit_root_1"
assert_equal "$claim_1_proof_rollup_exit_root" "$proof_rollup_exit_root_1"
log "β
First claim proofs validated successfully"
log "β
First claim all fields validated successfully"
log "π Validating third asset claim was processed"
log "Global index: $global_index_3"
run get_claim "$l2_rpc_network_id" "$global_index_3" 50 10 "$aggkit_bridge_url"
assert_success
local claim_3="$output"
log "π Third claim response: $claim_3"
# Validate all parameters for third claim
log "π Validating all parameters for third claim"
local claim_3_mainnet_exit_root
claim_3_mainnet_exit_root=$(echo "$claim_3" | jq -r '.mainnet_exit_root')
local claim_3_rollup_exit_root
claim_3_rollup_exit_root=$(echo "$claim_3" | jq -r '.rollup_exit_root')
local claim_3_global_exit_root
claim_3_global_exit_root=$(echo "$claim_3" | jq -r '.global_exit_root')
local claim_3_origin_network
claim_3_origin_network=$(echo "$claim_3" | jq -r '.origin_network')
local claim_3_origin_address
claim_3_origin_address=$(echo "$claim_3" | jq -r '.origin_address')
local claim_3_destination_network
claim_3_destination_network=$(echo "$claim_3" | jq -r '.destination_network')
local claim_3_destination_address
claim_3_destination_address=$(echo "$claim_3" | jq -r '.destination_address')
local claim_3_amount
claim_3_amount=$(echo "$claim_3" | jq -r '.amount')
local claim_3_metadata
claim_3_metadata=$(echo "$claim_3" | jq -r '.metadata')
log "π³ Third claim mainnet exit root: $claim_3_mainnet_exit_root (Expected: $mainnet_exit_root_3)"
log "π³ Third claim rollup exit root: $claim_3_rollup_exit_root (Expected: $rollup_exit_root_3)"
log "π³ Third claim global exit root: $claim_3_global_exit_root"
log "π Third claim origin network: $claim_3_origin_network (Expected: $origin_network_3)"
log "π Third claim origin address: $claim_3_origin_address (Expected: $origin_address_3)"
log "π Third claim destination network: $claim_3_destination_network (Expected: $destination_network_3)"
log "π Third claim destination address: $claim_3_destination_address (Expected: $destination_address_3)"
log "π° Third claim amount: $claim_3_amount (Expected: $amount_3)"
log "π Third claim metadata: $claim_3_metadata (Expected: $metadata_3)"
# Verify all field values match expected values
assert_equal "$claim_3_mainnet_exit_root" "$mainnet_exit_root_3"
assert_equal "$claim_3_rollup_exit_root" "$rollup_exit_root_3"
assert_equal "$claim_3_origin_network" "$origin_network_3"
assert_equal "$claim_3_origin_address" "$origin_address_3"
assert_equal "$claim_3_destination_network" "$destination_network_3"
assert_equal "$claim_3_destination_address" "$destination_address_3"
assert_equal "$claim_3_amount" "$amount_3"
assert_equal "$claim_3_metadata" "$metadata_3"
# Validate proofs for third claim
log "π Validating proofs for third claim"
local claim_3_proof_local_exit_root
claim_3_proof_local_exit_root=$(echo "$claim_3" | jq -r '.proof_local_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
local claim_3_proof_rollup_exit_root
claim_3_proof_rollup_exit_root=$(echo "$claim_3" | jq -r '.proof_rollup_exit_root | join(",")' | sed 's/^/[/' | sed 's/$/]/')
log "π Third claim proof local exit root: $claim_3_proof_local_exit_root"
log "π Expected proof local exit root: $proof_local_exit_root_3"
log "π Third claim proof rollup exit root: $claim_3_proof_rollup_exit_root"
log "π Expected proof rollup exit root: $proof_rollup_exit_root_3"
# Verify proof values match expected values
assert_equal "$claim_3_proof_local_exit_root" "$proof_local_exit_root_3"
assert_equal "$claim_3_proof_rollup_exit_root" "$proof_rollup_exit_root_3"
log "β
Third claim proofs validated successfully"
log "β
Third claim all fields validated successfully"
# ========================================
# STEP 8: Validate that failed claims are not returned by the claims API
# ========================================
log "π STEP 8: Validating that failed claim (second) is not returned by the claims API"
# Get all claims from the API to check if failed claims are present
log "π Getting all claims from the API"
local all_claims_result
all_claims_result=$(curl -s -H "Content-Type: application/json" "$aggkit_bridge_url/bridge/v1/claims?network_id=$l2_rpc_network_id")
log "π All claims response: $all_claims_result"
# Check if second claim (failed) is present in the API response
log "π Checking if second claim (failed) with global_index $global_index_2 is present in API response"
local second_claim_found=false
for row in $(echo "$all_claims_result" | jq -c '.claims[]'); do
local claim_global_index
claim_global_index=$(jq -r '.global_index' <<<"$row")
if [[ "$claim_global_index" == "$global_index_2" ]]; then
second_claim_found=true
log "β ERROR: Second claim with global_index $global_index_2 was found in API response, but it should have failed"
log "π Second claim details: $row"
break
fi
done
if [[ "$second_claim_found" == "false" ]]; then
log "β
Second claim with global_index $global_index_2 correctly NOT found in API response (failed as expected)"
else
log "β ERROR: Second claim with global_index $global_index_2 should not be in API response since it failed"
exit 1
fi
log "β
Failed claims validation completed successfully"
log "β
Failed claims (second) correctly NOT present in API response"
else
log "β onMessageReceived transaction failed"
log "$on_message_output"
exit 1
fi
log "π Test triple claim internal calls -> 1 success, 1 fail and 1 success completed successfully"
log "π Summary:"
log " β
First asset bridge created and parameters extracted"
log " β
Second asset bridge created and malformed parameters prepared"
log " β
Third asset bridge created and parameters extracted"
log " β
Fourth asset bridge created and parameters extracted"
log " β
All four sets of parameters configured in contract"
log " β
First claim processed successfully"
log " β
Second claim failed as expected (malformed parameters)"
log " β
Third claim processed successfully"
}
@test "Test triple claim internal calls -> 1 fail, 1 success and 1 fail" {
log "π§ͺ Testing triple claim internal calls: 1 fail, 1 success, 1 fail"
# ========================================
# STEP 1: Bridge first asset and get all claim parameters
# ========================================
log "π STEP 1: Bridging first asset from L1 to L2"
destination_addr=$sender_addr
destination_net=$l2_rpc_network_id
# Bridge first asset using the helper function
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_1=$output
log "π First bridge asset transaction hash: $bridge_tx_hash_1"
# Extract claim parameters for first asset
local claim_params_1
claim_params_1=$(extract_claim_parameters_json "$bridge_tx_hash_1" "first" "$l1_rpc_network_id" "$sender_addr")
local proof_local_exit_root_1
proof_local_exit_root_1=$(echo "$claim_params_1" | jq -r '.proof_local_exit_root')
local proof_rollup_exit_root_1
proof_rollup_exit_root_1=$(echo "$claim_params_1" | jq -r '.proof_rollup_exit_root')
local global_index_1
global_index_1=$(echo "$claim_params_1" | jq -r '.global_index')
local mainnet_exit_root_1
mainnet_exit_root_1=$(echo "$claim_params_1" | jq -r '.mainnet_exit_root')
local rollup_exit_root_1
rollup_exit_root_1=$(echo "$claim_params_1" | jq -r '.rollup_exit_root')
local origin_network_1
origin_network_1=$(echo "$claim_params_1" | jq -r '.origin_network')
local origin_address_1
origin_address_1=$(echo "$claim_params_1" | jq -r '.origin_address')
local destination_network_1
destination_network_1=$(echo "$claim_params_1" | jq -r '.destination_network')
local destination_address_1
destination_address_1=$(echo "$claim_params_1" | jq -r '.destination_address')
local amount_1
amount_1=$(echo "$claim_params_1" | jq -r '.amount')
local metadata_1
metadata_1=$(echo "$claim_params_1" | jq -r '.metadata')
log "β
First asset claim parameters extracted successfully"
# ========================================
# STEP 2: Bridge second asset and get all claim parameters
# ========================================
log "π STEP 2: Bridging second asset from L1 to L2"
run bridge_asset "$native_token_addr" "$l1_rpc_url" "$l1_bridge_addr"
assert_success
local bridge_tx_hash_2=$output
log "π Second bridge asset transaction hash: $bridge_tx_hash_2"
# Extract claim parameters for second asset
local claim_params_2