2

Let's say I have the following stylus contract:

#![cfg_attr(not(feature = "export-abi"), no_main)]
extern crate alloc;
use stylus_sdk::{
    alloy_primitives::U256,
    prelude::{entrypoint, external, sol_storage},
};


sol_storage! {
    #[entrypoint]
    pub struct SimpleStorage {
        uint256 my_favorite_number;
    }
}

#[external]
impl SimpleStorage {
    pub fn store(&mut self, new_number: U256) -> Result<(), Vec<u8>> {
        self.my_favorite_number.set(new_number);
        Ok(())
    }

    pub fn retrieve(&self) -> Result<U256, Vec<u8>> {
        Ok(self.my_favorite_number.get())
    }
}

How would I write a unit test for this? Where would I put the unit test?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.