@@ -2082,16 +2082,18 @@ TEST_CASE("state archival", "[tx][soroban]")
2082
2082
cfg.mWriteFee1KBBucketListLow = 20'000 ;
2083
2083
cfg.mWriteFee1KBBucketListHigh = 1'000'000 ;
2084
2084
});
2085
- auto const & stateArchivalSettings =
2086
- test.getNetworkCfg ().stateArchivalSettings ();
2085
+
2086
+ auto getArchivalSettings = [&]() {
2087
+ return test.getNetworkCfg ().stateArchivalSettings ();
2088
+ };
2087
2089
auto isSuccess = [](auto resultCode) {
2088
2090
return resultCode == INVOKE_HOST_FUNCTION_SUCCESS;
2089
2091
};
2090
2092
ContractStorageTestClient client (test);
2091
2093
SECTION (" contract instance and Wasm archival" )
2092
2094
{
2093
2095
uint32_t originalExpectedLiveUntilLedger =
2094
- test.getLCLSeq () + stateArchivalSettings .minPersistentTTL - 1 ;
2096
+ test.getLCLSeq () + getArchivalSettings () .minPersistentTTL - 1 ;
2095
2097
2096
2098
for (uint32_t i =
2097
2099
test.getApp ().getLedgerManager ().getLastClosedLedgerNum ();
@@ -2121,7 +2123,7 @@ TEST_CASE("state archival", "[tx][soroban]")
2121
2123
40000 /* two LE-writes
2122
2124
*/ );
2123
2125
auto newExpectedLiveUntilLedger =
2124
- test.getLCLSeq () + stateArchivalSettings .minPersistentTTL - 1 ;
2126
+ test.getLCLSeq () + getArchivalSettings () .minPersistentTTL - 1 ;
2125
2127
2126
2128
// Instance should now be useable
2127
2129
REQUIRE (isSuccess (
@@ -2137,7 +2139,7 @@ TEST_CASE("state archival", "[tx][soroban]")
2137
2139
939 /* rent bump */ +
2138
2140
20000 /* one LE write */ );
2139
2141
auto newExpectedLiveUntilLedger =
2140
- test.getLCLSeq () + stateArchivalSettings .minPersistentTTL - 1 ;
2142
+ test.getLCLSeq () + getArchivalSettings () .minPersistentTTL - 1 ;
2141
2143
2142
2144
// invocation should fail
2143
2145
REQUIRE (client.put (" temp" , ContractDataDurability::TEMPORARY, 0 ) ==
@@ -2155,7 +2157,7 @@ TEST_CASE("state archival", "[tx][soroban]")
2155
2157
943 /* rent bump */ +
2156
2158
20000 /* one LE write */ );
2157
2159
auto newExpectedLiveUntilLedger =
2158
- test.getLCLSeq () + stateArchivalSettings .minPersistentTTL - 1 ;
2160
+ test.getLCLSeq () + getArchivalSettings () .minPersistentTTL - 1 ;
2159
2161
2160
2162
// invocation should fail
2161
2163
REQUIRE (client.put (" temp" , ContractDataDurability::TEMPORARY, 0 ) ==
@@ -2194,7 +2196,7 @@ TEST_CASE("state archival", "[tx][soroban]")
2194
2196
REQUIRE (isSuccess (
2195
2197
client.put (" temp" , ContractDataDurability::TEMPORARY, 0 )));
2196
2198
auto expectedTempLiveUntilLedger =
2197
- test.getLCLSeq () + stateArchivalSettings .minTemporaryTTL - 1 ;
2199
+ test.getLCLSeq () + getArchivalSettings () .minTemporaryTTL - 1 ;
2198
2200
2199
2201
// Check for expected minimum lifetime values
2200
2202
REQUIRE (
@@ -2274,7 +2276,7 @@ TEST_CASE("state archival", "[tx][soroban]")
2274
2276
2275
2277
// Recreated entry should be live
2276
2278
REQUIRE (client.getTTL (" temp" , ContractDataDurability::TEMPORARY) ==
2277
- test.getLCLSeq () + stateArchivalSettings .minTemporaryTTL -
2279
+ test.getLCLSeq () + getArchivalSettings () .minTemporaryTTL -
2278
2280
1 );
2279
2281
REQUIRE (isSuccess (
2280
2282
client.get (" temp" , ContractDataDurability::TEMPORARY, 42 )));
@@ -2329,7 +2331,7 @@ TEST_CASE("state archival", "[tx][soroban]")
2329
2331
makeSymbolSCVal (" persistent2" ),
2330
2332
ContractDataDurability::PERSISTENT);
2331
2333
uint32_t expectedLiveUntilLedger2 =
2332
- test.getLCLSeq () + stateArchivalSettings .minPersistentTTL - 1 ;
2334
+ test.getLCLSeq () + getArchivalSettings () .minPersistentTTL - 1 ;
2333
2335
REQUIRE (client.getTTL (" persistent2" ,
2334
2336
ContractDataDurability::PERSISTENT) ==
2335
2337
expectedLiveUntilLedger2);
@@ -2347,7 +2349,7 @@ TEST_CASE("state archival", "[tx][soroban]")
2347
2349
// Check value and TTL of restored entry
2348
2350
REQUIRE (client.getTTL (" persistent" ,
2349
2351
ContractDataDurability::PERSISTENT) ==
2350
- test.getLCLSeq () + stateArchivalSettings .minPersistentTTL -
2352
+ test.getLCLSeq () + getArchivalSettings () .minPersistentTTL -
2351
2353
1 );
2352
2354
REQUIRE (isSuccess (client.get (
2353
2355
" persistent" , ContractDataDurability::PERSISTENT, 10 )));
@@ -2432,12 +2434,12 @@ TEST_CASE("state archival", "[tx][soroban]")
2432
2434
REQUIRE (isSuccess (
2433
2435
client.put (" key" , ContractDataDurability::PERSISTENT, 0 )));
2434
2436
uint32_t initialLiveUntilLedger =
2435
- test.getLCLSeq () + stateArchivalSettings .minPersistentTTL - 1 ;
2437
+ test.getLCLSeq () + getArchivalSettings () .minPersistentTTL - 1 ;
2436
2438
REQUIRE (client.getTTL (" key" , ContractDataDurability::PERSISTENT) ==
2437
2439
initialLiveUntilLedger);
2438
2440
// Try extending entry, but set the threshold 1 ledger below the
2439
2441
// current TTL.
2440
- uint32_t currentTTL = stateArchivalSettings .minPersistentTTL - 2 ;
2442
+ uint32_t currentTTL = getArchivalSettings () .minPersistentTTL - 2 ;
2441
2443
REQUIRE (
2442
2444
isSuccess (client.extend (" key" , ContractDataDurability::PERSISTENT,
2443
2445
currentTTL - 1 , 50'000 )));
@@ -2467,9 +2469,9 @@ TEST_CASE("state archival", "[tx][soroban]")
2467
2469
SECTION (" extension op" )
2468
2470
{
2469
2471
// Max TTL includes current ledger, so subtract 1
2470
- test.invokeExtendOp ({lk}, stateArchivalSettings .maxEntryTTL - 1 );
2472
+ test.invokeExtendOp ({lk}, getArchivalSettings () .maxEntryTTL - 1 );
2471
2473
REQUIRE (test.getTTL (lk) ==
2472
- test.getLCLSeq () + stateArchivalSettings .maxEntryTTL - 1 );
2474
+ test.getLCLSeq () + getArchivalSettings () .maxEntryTTL - 1 );
2473
2475
}
2474
2476
2475
2477
SECTION (" extend host function persistent" )
@@ -2480,14 +2482,14 @@ TEST_CASE("state archival", "[tx][soroban]")
2480
2482
2481
2483
REQUIRE (isSuccess (client.extend (
2482
2484
" key" , ContractDataDurability::PERSISTENT,
2483
- stateArchivalSettings .maxEntryTTL + 10 ,
2484
- stateArchivalSettings .maxEntryTTL + 10 ,
2485
+ getArchivalSettings () .maxEntryTTL + 10 ,
2486
+ getArchivalSettings () .maxEntryTTL + 10 ,
2485
2487
client.readKeySpec (" key" , ContractDataDurability::PERSISTENT)
2486
2488
.setRefundableResourceFee (80'000 ))));
2487
2489
2488
2490
// Capped at max (Max TTL includes current ledger, so subtract 1)
2489
2491
REQUIRE (test.getTTL (lk) ==
2490
- test.getLCLSeq () + stateArchivalSettings .maxEntryTTL - 1 );
2492
+ test.getLCLSeq () + getArchivalSettings () .maxEntryTTL - 1 );
2491
2493
}
2492
2494
2493
2495
SECTION (" extend host function temp" )
@@ -2498,19 +2500,19 @@ TEST_CASE("state archival", "[tx][soroban]")
2498
2500
makeSymbolSCVal (" key" ), ContractDataDurability::TEMPORARY);
2499
2501
uint32_t ledgerSeq = test.getLCLSeq ();
2500
2502
REQUIRE (client.extend (" key" , ContractDataDurability::TEMPORARY,
2501
- stateArchivalSettings .maxEntryTTL ,
2502
- stateArchivalSettings .maxEntryTTL ) ==
2503
+ getArchivalSettings () .maxEntryTTL ,
2504
+ getArchivalSettings () .maxEntryTTL ) ==
2503
2505
INVOKE_HOST_FUNCTION_TRAPPED);
2504
2506
REQUIRE (test.getTTL (lkTemp) ==
2505
- ledgerSeq + stateArchivalSettings .minTemporaryTTL - 1 );
2507
+ ledgerSeq + getArchivalSettings () .minTemporaryTTL - 1 );
2506
2508
2507
2509
// Max TTL includes current ledger, so subtract 1
2508
2510
REQUIRE (isSuccess (
2509
2511
client.extend (" key" , ContractDataDurability::TEMPORARY,
2510
- stateArchivalSettings .maxEntryTTL - 1 ,
2511
- stateArchivalSettings .maxEntryTTL - 1 )));
2512
+ getArchivalSettings () .maxEntryTTL - 1 ,
2513
+ getArchivalSettings () .maxEntryTTL - 1 )));
2512
2514
REQUIRE (test.getTTL (lkTemp) ==
2513
- test.getLCLSeq () + stateArchivalSettings .maxEntryTTL - 1 );
2515
+ test.getLCLSeq () + getArchivalSettings () .maxEntryTTL - 1 );
2514
2516
}
2515
2517
}
2516
2518
}
0 commit comments