Skip to content

Testing randomness functions #455

Discussion options

You must be logged in to vote

gm gm @enderNakamoto @adipundir this error suggests that the PerBlockRandomness resource is not under the module for testing which is the case. So for tests we have a function called initialize_for_testing that sets the seed and creates this resource.

From randomness.move core file

 /// Must be called in tests to initialize the PerBlockRandomness resource.
public fun initialize(framework: &signer) {
        system_addresses::assert_aptos_framework(framework);
        if (!exists<PerBlockRandomness>(@aptos_framework)) {
            move_to(framework, PerBlockRandomness {
                epoch: 0,
                round: 0,
                seed: option::none(),
            });
        }
    …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by enderNakamoto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants