Skip to content

Commit

Permalink
Init tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MightOfOaks committed Aug 31, 2023
1 parent 3cfd65f commit 90ff5b6
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contracts/vip/collection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ cw721-base = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
sg-std = { workspace = true }

[dev-dependencies]
cw-multi-test = { workspace = true }
sg-multi-test = { workspace = true }
14 changes: 13 additions & 1 deletion contracts/vip/collection/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,16 @@ pub fn query_total_staked(deps: Deps, owner: String) -> StdResult<Binary> {
}

#[cfg(test)]
mod tests {}
mod tests {
use cw_multi_test::{Contract, ContractWrapper};
use sg_std::StargazeMsgWrapper;

fn minter_contract() -> Box<dyn Contract<StargazeMsgWrapper>> {
let contract = ContractWrapper::new(
crate::contract::instantiate,
crate::contract::execute,
crate::contract::query,
);
Box::new(contract)
}
}
3 changes: 3 additions & 0 deletions contracts/vip/minter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ cw721-base = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
sg-multi-test = { workspace = true }
sg-std = { workspace = true }
sg-name = "1.2.5"
stargaze-vip-collection = { path = "../collection", features = ["library"] }

[dev-dependencies]
cw-multi-test = { workspace = true }
sg-multi-test = { workspace = true }
28 changes: 20 additions & 8 deletions contracts/vip/minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ pub fn instantiate(
salt: Binary::from(salt.to_vec()),
};

let event = Event::new("instantiate").add_attribute("collection", collection);

Ok(Response::new()
.add_message(collection_init_msg)
.add_attribute("collection", collection))
.add_event(event))
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down Expand Up @@ -115,11 +117,11 @@ pub fn execute_mint(
Ok(names)
})?;

NAME_UPDATE_HEIGHT.update(deps.storage, name, |height| -> StdResult<_> {
NAME_UPDATE_HEIGHT.update(deps.storage, name, |_| -> StdResult<_> {
Ok(env.block.height)
})?;

Ok(Response::new().add_message(mint_msg))
let event = Event::new("mint");
Ok(Response::new().add_message(mint_msg).add_event(event))
}

pub fn execute_update(
Expand Down Expand Up @@ -152,11 +154,11 @@ pub fn execute_update(
vip_collection,
)?;

NAME_UPDATE_HEIGHT.update(deps.storage, name, |height| -> StdResult<_> {
NAME_UPDATE_HEIGHT.update(deps.storage, name, |_| -> StdResult<_> {
Ok(env.block.height)
})?;

Ok(Response::new().add_message(mint_msg))
let event = Event::new("update");
Ok(Response::new().add_message(mint_msg).add_event(event))
}

pub fn mint(
Expand Down Expand Up @@ -269,4 +271,14 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
}

#[cfg(test)]
mod tests {}
mod tests {
use crate::sudo;
use cw_multi_test::{Contract, ContractWrapper};
use sg_std::StargazeMsgWrapper;

fn minter_contract() -> Box<dyn Contract<StargazeMsgWrapper>> {
let contract = ContractWrapper::new(super::execute, super::instantiate, super::query)
.with_sudo(sudo::sudo);
Box::new(contract)
}
}
4 changes: 2 additions & 2 deletions contracts/vip/minter/src/sudo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> Result<Response, ContractE
}
}

pub fn sudo_begin_block(deps: DepsMut, env: Env) -> Result<Response, ContractError> {
pub fn sudo_begin_block(_deps: DepsMut, _env: Env) -> Result<Response, ContractError> {
Ok(Response::new())
}

pub fn sudo_end_block(deps: DepsMut, env: Env) -> Result<Response, ContractError> {
pub fn sudo_end_block(_deps: DepsMut, _env: Env) -> Result<Response, ContractError> {
/*let Config {
vip_collection,
update_interval,
Expand Down

0 comments on commit 90ff5b6

Please sign in to comment.