Skip to content

Commit 7c7be0d

Browse files
authored
Merge pull request #244 from blueshift-gg/fix-warp-to-slot-in-mollusk-course
fix: call wrap_to_slot as a method
2 parents cf4a382 + ebafa46 commit 7c7be0d

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

src/app/content/courses/testing-with-mollusk/advanced-functionalities/de.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,6 @@ fn test() {
458458
mollusk.sysvars.clock.unix_timestamp = 1234567890;
459459

460460
// Jump to Slot 1000
461-
warp_to_slot(&mut Mollusk, 1000)
461+
mollusk.warp_to_slot(1000);
462462
}
463463
```

src/app/content/courses/testing-with-mollusk/advanced-functionalities/en.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,6 @@ fn test() {
458458
mollusk.sysvars.clock.unix_timestamp = 1234567890;
459459

460460
// Jump to Slot 1000
461-
warp_to_slot(&mut Mollusk, 1000)
461+
mollusk.warp_to_slot(1000);
462462
}
463463
```

src/app/content/courses/testing-with-mollusk/advanced-functionalities/fr.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,6 @@ fn test() {
491491
mollusk.sysvars.clock.unix_timestamp = 1234567890;
492492

493493
// Jump to Slot 1000
494-
warp_to_slot(&mut Mollusk, 1000)
494+
mollusk.warp_to_slot(1000);
495495
}
496496
```

src/app/content/courses/testing-with-mollusk/advanced-functionalities/id.mdx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn test() {
5656

5757
// Load the program into your mollusk instance
5858
mollusk.add_program(
59-
&ID,
59+
&ID,
6060
"target/deploy/program",
6161
&mollusk_svm::program::loader_keys::LOADER_V3
6262
);
@@ -93,11 +93,11 @@ Dan buat referensi akun yang diperlukan untuk skenario pengujian Anda:
9393

9494
```rust
9595
// SPL Token Program
96-
let (token_program, token_program_account) =
96+
let (token_program, token_program_account) =
9797
mollusk_svm_programs_token::token::keyed_account();
9898

9999
// Token2022 Program
100-
let (token2022_program, token2022_program_account) =
100+
let (token2022_program, token2022_program_account) =
101101
mollusk_svm_programs_token::token2022::keyed_account();
102102

103103
// Associated Token Program
@@ -301,24 +301,24 @@ Setelah didefinisikan, custom syscall harus didaftarkan ke lingkungan runtime pr
301301
fn test_custom_syscall() {
302302
std::env::set_var("SBF_OUT_DIR", "../target/deploy");
303303
let program_id = Pubkey::new_unique();
304-
304+
305305
let mollusk = {
306306
let mut mollusk = Mollusk::default();
307-
307+
308308
// Register the custom syscall with a specific name
309309
mollusk
310310
.program_cache
311311
.program_runtime_environment
312312
.register_function("sol_burn_cus", SyscallBurnCus::vm)
313313
.unwrap();
314-
314+
315315
// Add your program that uses the custom syscall
316316
mollusk.add_program(
317317
&program_id,
318318
"test_program_custom_syscall",
319319
&mollusk_svm::program::loader_keys::LOADER_V3,
320320
);
321-
321+
322322
mollusk
323323
};
324324
}
@@ -338,7 +338,7 @@ fn instruction_burn_cus(program_id: &Pubkey, to_burn: u64) -> Instruction {
338338
#[test]
339339
fn test_custom_syscall() {
340340
// ... mollusk setup ...
341-
341+
342342
// Establish baseline compute unit usage
343343
let base_cus = mollusk
344344
.process_and_validate_instruction(
@@ -347,7 +347,7 @@ fn test_custom_syscall() {
347347
&[Check::success()],
348348
)
349349
.compute_units_consumed;
350-
350+
351351
// Test different compute unit consumption levels
352352
for to_burn in [100, 1_000, 10_000] {
353353
mollusk.process_and_validate_instruction(
@@ -366,7 +366,7 @@ fn test_custom_syscall() {
366366
367367
<ArticleSection name="Configuration Methods" id="configuration-methods" level="h2" />
368368

369-
Mollusk menyediakan opsi konfigurasi komprehensif yang memungkinkan Anda menyesuaikan lingkungan eksekusi agar sesuai dengan persyaratan pengujian tertentu seperti yang dapat kita lihat dari Mollusk `Context`:
369+
Mollusk menyediakan opsi konfigurasi komprehensif yang memungkinkan Anda menyesuaikan lingkungan eksekusi agar sesuai dengan persyaratan pengujian tertentu seperti yang dapat kita lihat dari Mollusk `Context`:
370370

371371
```rust
372372
/// Instruction context fixture.
@@ -399,13 +399,13 @@ use solana_sdk::feature_set::FeatureSet;
399399
#[test]
400400
fn test() {
401401
let mut mollusk = Mollusk::new(&program_id, "path/to/program.so");
402-
402+
403403
// Configure compute budget for performance testing
404404
mollusk.set_compute_budget(200_000);
405-
405+
406406
// Configure feature set to enable/disable specific Solana features
407407
mollusk.set_feature_set(FeatureSet::all_enabled());
408-
408+
409409
// Sysvars are handled automatically but can be customized if needed
410410
}
411411
```
@@ -437,7 +437,7 @@ Mollusk menyediakan akses ke semua variabel sistem (sysvars) yang dapat diquery
437437
/// Mollusk sysvars wrapper for easy manipulation
438438
pub struct Sysvars {
439439
pub clock: Clock, // Current slot, epoch, and timestamp
440-
pub epoch_rewards: EpochRewards, // Epoch reward distribution info
440+
pub epoch_rewards: EpochRewards, // Epoch reward distribution info
441441
pub epoch_schedule: EpochSchedule, // Epoch timing and slot configuration
442442
pub last_restart_slot: LastRestartSlot, // Last validator restart information
443443
pub rent: Rent, // Rent calculation parameters
@@ -452,12 +452,12 @@ Anda dapat menyesuaikan sysvars tertentu untuk menguji logika yang bergantung pa
452452
#[test]
453453
fn test() {
454454
let mut mollusk = Mollusk::new(&program_id, "path/to/program.so");
455-
455+
456456
// Customize clock for time-based testing
457457
mollusk.sysvars.clock.epoch = 10;
458458
mollusk.sysvars.clock.unix_timestamp = 1234567890;
459459

460460
// Jump to Slot 1000
461-
warp_to_slot(&mut Mollusk, 1000)
461+
mollusk.warp_to_slot(1000);
462462
}
463463
```

src/app/content/courses/testing-with-mollusk/advanced-functionalities/uk.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,6 @@ fn test() {
458458
mollusk.sysvars.clock.unix_timestamp = 1234567890;
459459

460460
// Jump to Slot 1000
461-
warp_to_slot(&mut Mollusk, 1000)
461+
mollusk.warp_to_slot(1000);
462462
}
463463
```

src/app/content/courses/testing-with-mollusk/advanced-functionalities/vi.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,6 @@ fn test() {
458458
mollusk.sysvars.clock.unix_timestamp = 1234567890;
459459

460460
// Jump to Slot 1000
461-
warp_to_slot(&mut Mollusk, 1000)
461+
mollusk.warp_to_slot(1000);
462462
}
463463
```

src/app/content/courses/testing-with-mollusk/advanced-functionalities/zh-CN.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,6 @@ fn test() {
458458
mollusk.sysvars.clock.unix_timestamp = 1234567890;
459459

460460
// Jump to Slot 1000
461-
warp_to_slot(&mut Mollusk, 1000)
461+
mollusk.warp_to_slot(1000);
462462
}
463463
```

src/app/content/courses/testing-with-mollusk/advanced-functionalities/zh-HK.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn test() {
5656

5757
// Load the program into your mollusk instance
5858
mollusk.add_program(
59-
&ID,
59+
&ID,
6060
"target/deploy/program",
6161
&mollusk_svm::program::loader_keys::LOADER_V3
6262
);
@@ -93,11 +93,11 @@ fn test() {
9393

9494
```rust
9595
// SPL Token Program
96-
let (token_program, token_program_account) =
96+
let (token_program, token_program_account) =
9797
mollusk_svm_programs_token::token::keyed_account();
9898

9999
// Token2022 Program
100-
let (token2022_program, token2022_program_account) =
100+
let (token2022_program, token2022_program_account) =
101101
mollusk_svm_programs_token::token2022::keyed_account();
102102

103103
// Associated Token Program
@@ -301,24 +301,24 @@ declare_builtin_function!(
301301
fn test_custom_syscall() {
302302
std::env::set_var("SBF_OUT_DIR", "../target/deploy");
303303
let program_id = Pubkey::new_unique();
304-
304+
305305
let mollusk = {
306306
let mut mollusk = Mollusk::default();
307-
307+
308308
// Register the custom syscall with a specific name
309309
mollusk
310310
.program_cache
311311
.program_runtime_environment
312312
.register_function("sol_burn_cus", SyscallBurnCus::vm)
313313
.unwrap();
314-
314+
315315
// Add your program that uses the custom syscall
316316
mollusk.add_program(
317317
&program_id,
318318
"test_program_custom_syscall",
319319
&mollusk_svm::program::loader_keys::LOADER_V3,
320320
);
321-
321+
322322
mollusk
323323
};
324324
}
@@ -338,7 +338,7 @@ fn instruction_burn_cus(program_id: &Pubkey, to_burn: u64) -> Instruction {
338338
#[test]
339339
fn test_custom_syscall() {
340340
// ... mollusk setup ...
341-
341+
342342
// Establish baseline compute unit usage
343343
let base_cus = mollusk
344344
.process_and_validate_instruction(
@@ -347,7 +347,7 @@ fn test_custom_syscall() {
347347
&[Check::success()],
348348
)
349349
.compute_units_consumed;
350-
350+
351351
// Test different compute unit consumption levels
352352
for to_burn in [100, 1_000, 10_000] {
353353
mollusk.process_and_validate_instruction(
@@ -399,13 +399,13 @@ use solana_sdk::feature_set::FeatureSet;
399399
#[test]
400400
fn test() {
401401
let mut mollusk = Mollusk::new(&program_id, "path/to/program.so");
402-
402+
403403
// Configure compute budget for performance testing
404404
mollusk.set_compute_budget(200_000);
405-
405+
406406
// Configure feature set to enable/disable specific Solana features
407407
mollusk.set_feature_set(FeatureSet::all_enabled());
408-
408+
409409
// Sysvars are handled automatically but can be customized if needed
410410
}
411411
```
@@ -437,7 +437,7 @@ Mollusk 提供對所有系統變數(sysvars)的訪問,程式可以在執
437437
/// Mollusk sysvars wrapper for easy manipulation
438438
pub struct Sysvars {
439439
pub clock: Clock, // Current slot, epoch, and timestamp
440-
pub epoch_rewards: EpochRewards, // Epoch reward distribution info
440+
pub epoch_rewards: EpochRewards, // Epoch reward distribution info
441441
pub epoch_schedule: EpochSchedule, // Epoch timing and slot configuration
442442
pub last_restart_slot: LastRestartSlot, // Last validator restart information
443443
pub rent: Rent, // Rent calculation parameters
@@ -452,12 +452,12 @@ pub struct Sysvars {
452452
#[test]
453453
fn test() {
454454
let mut mollusk = Mollusk::new(&program_id, "path/to/program.so");
455-
455+
456456
// Customize clock for time-based testing
457457
mollusk.sysvars.clock.epoch = 10;
458458
mollusk.sysvars.clock.unix_timestamp = 1234567890;
459459

460460
// Jump to Slot 1000
461-
warp_to_slot(&mut Mollusk, 1000)
461+
mollusk.warp_to_slot(1000);
462462
}
463463
```

0 commit comments

Comments
 (0)