Skip to content

Commit

Permalink
feat(objectarium): do not allow funds on instantiate
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Jun 4, 2024
1 parent 474823e commit d068844
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/axone-cognitarium/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ mod tests {
}

#[test]
fn instantiate_fail_with_funds() {
fn funds_initialization() {
let mut deps = mock_dependencies();
let env = mock_env();
let info = mock_info("sender", &coins(10, "uaxone"));
Expand Down
2 changes: 1 addition & 1 deletion contracts/axone-dataverse/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ mod tests {
}

#[test]
fn instantiate_fail_with_funds() {
fn funds_initialization() {
let mut deps = mock_dependencies();
let env = mock_env();
let info = mock_info("sender", &coins(10, "uaxone"));
Expand Down
2 changes: 1 addition & 1 deletion contracts/axone-law-stone/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ mod tests {
}

#[test]
fn instantiate_fail_with_funds() {
fn funds_initialization() {
let mut deps =
mock_dependencies_with_logic_handler(|_| SystemResult::Err(SystemError::Unknown {}));
let env = mock_env();
Expand Down
20 changes: 20 additions & 0 deletions contracts/axone-objectarium/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub fn instantiate(
info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
nonpayable(&info)?;
let bucket = Bucket::try_new(
info.sender,
msg.bucket,
Expand Down Expand Up @@ -650,6 +651,25 @@ mod tests {
assert_eq!("foobar", value.name);
}

#[test]
fn funds_initialization() {
let mut deps = mock_dependencies();
let msg = InstantiateMsg {
bucket: "foo".to_string(),
config: Default::default(),
limits: Default::default(),
pagination: Default::default(),
};
let info = mock_info("creator", &coins(10, "uaxone"));

let res = instantiate(deps.as_mut(), mock_env(), info, msg);
assert!(res.is_err());
assert_eq!(
res.unwrap_err(),
ContractError::Payment(PaymentError::NonPayable {})
);
}

#[test]
fn execute_fail_with_funds() {
let mut deps = mock_dependencies();
Expand Down

0 comments on commit d068844

Please sign in to comment.