Skip to content

Commit

Permalink
Fixed Tests. Mops Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
panindustrial-dev committed Jan 4, 2024
1 parent 1ff5c03 commit 1e70d7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion mops.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "icrc30-mo"
version = "0.2.0"
version = "0.3.1"
description = "icrc30 for motoko"
repository = "https://github.com/PanIndustrial-Org/icrc30.mo"
keywords = [ "nft" ]
Expand Down
32 changes: 15 additions & 17 deletions test/lib.test.mo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ICRC30 "../src";
import ICRC7 "mo:icrc7.mo";
import ICRC7 "mo:icrc7-mo";
import Principal "mo:base/Principal";
import CandyTypesLib "mo:candy_0_3_0/types";
import CandyConv "mo:candy_0_3_0/conversion";
Expand Down Expand Up @@ -364,16 +364,14 @@ test("Approve another account for all transfers in the collection and paginate q
spender = approvedSpender;
};

let approvalResponse = icrc30.approve_collection(testOwner, approvalArgs);
let approvalResponse1 = icrc30.approve_collection(testOwner, {approvalArgs with spender = spender2});
let approvalResponse2 = icrc30.approve_collection(testOwner, {approvalArgs with spender = spender3});
let approvalResponse3 = icrc30.approve_collection(testOwner, {approvalArgs with spender = spender4});
let approvalResponse4 = icrc30.approve_collection(testOwner, {approvalArgs with spender = spender5});
let approvalResponse = icrc30.approve_collection_transfers(testOwner, approvalArgs);
let approvalResponse1 = icrc30.approve_collection_transfers(testOwner, {approvalArgs with spender = spender2});
let approvalResponse2 = icrc30.approve_collection_transfers(testOwner, {approvalArgs with spender = spender3});
let approvalResponse3 = icrc30.approve_collection_transfers(testOwner, {approvalArgs with spender = spender4});
let approvalResponse4 = icrc30.approve_collection_transfers(testOwner, {approvalArgs with spender = spender5});

D.print("Approval results: " # debug_show(approvalResponse, approvalResponse1, approvalResponse2, approvalResponse3, approvalResponse4));




switch(approvalResponse, approvalResponse1, approvalResponse2, approvalResponse3, approvalResponse4){
case(#ok(#Ok(_)),#ok(#Ok(_)),#ok(#Ok(_)),#ok(#Ok(_)),#ok(#Ok(_))){};
Expand Down Expand Up @@ -450,9 +448,9 @@ test("Check collection approval requests for expiry and creation times", func()
};

// Act: Attempt collection approval requests with expired and future timestamps
let #err(approvalResponsesExpired) = icrc30.approve_collection(testOwner, invalidApprovalInfo1) else return assert(false);
let #ok(#Err(approvalResponsesFuture)) = icrc30.approve_collection(testOwner, invalidApprovalInfo2) else return assert(false);
let #ok(#Err(approvalResponsesOld)) = icrc30.approve_collection(testOwner, invalidApprovalInfo3) else return assert(false);
let #err(approvalResponsesExpired) = icrc30.approve_collection_transfers(testOwner, invalidApprovalInfo1) else return assert(false);
let #ok(#Err(approvalResponsesFuture)) = icrc30.approve_collection_transfers(testOwner, invalidApprovalInfo2) else return assert(false);
let #ok(#Err(approvalResponsesOld)) = icrc30.approve_collection_transfers(testOwner, invalidApprovalInfo3) else return assert(false);

D.print("Approval results: " # debug_show(approvalResponsesExpired, approvalResponsesFuture, approvalResponsesOld));

Expand Down Expand Up @@ -648,7 +646,7 @@ test("Transfer a token to another account after collection approval", func() {
};

// Create the approval for the token transfer
let approvalResponses = icrc30.approve_collection(tokenOwner, approvalInfo);
let approvalResponses = icrc30.approve_collection_transfers(tokenOwner, approvalInfo);

assert(icrc30.is_approved(spender, null, 1));

Expand Down Expand Up @@ -813,7 +811,7 @@ test("Transfer a token to another account after collection approval", func() {
};

// Create the approval for the token transfer
let approvalResponses = icrc30.approve_collection(tokenOwner, approvalInfo);
let approvalResponses = icrc30.approve_collection_transfers(tokenOwner, approvalInfo);

assert(icrc30.is_approved(spender, null, 1));

Expand Down Expand Up @@ -1083,7 +1081,7 @@ test("Revoke single collection approvals for an account", func() {
memo = null;
created_at_time = ?init_time;
};
let #ok(#Ok(revokeResponse)) = icrc30.revoke_collection_approvals(tokenOwner, revokeArgs) else return assert(false);
let #ok(#Ok(revokeResponse)) = icrc30.revoke_collection(tokenOwner, revokeArgs) else return assert(false);

for (response in revokeResponse.vals()) {
assert(
Expand Down Expand Up @@ -1171,7 +1169,7 @@ test("Revoke all collection approvals for an account", func() {
created_at_time = ?init_time;
memo = null;
};
let #ok(#Ok(revokeResponse)) = icrc30.revoke_collection_approvals(tokenOwner, revokeArgs) else return assert(false);
let #ok(#Ok(revokeResponse)) = icrc30.revoke_collection(tokenOwner, revokeArgs) else return assert(false);

for (response in revokeResponse.vals()) {
assert(
Expand Down Expand Up @@ -1272,8 +1270,8 @@ test("Attempt to revoke approvals with duplicate or empty token ID arrays", func
};

// Act: Attempt revoke requests with duplicate and empty token ID arrays
let revocationResponsesWithDuplicates = icrc30.revoke_token_approvals(tokenOwner, {token_ids=tokenIdsWithDuplicates; spender=?spender; from_subaccount=null; created_at_time=null; memo=null;});
let revocationResponsesEmpty = icrc30.revoke_token_approvals(tokenOwner, {token_ids=emptyTokenIds; spender=?spender; from_subaccount=null; created_at_time=null; memo=null;});
let revocationResponsesWithDuplicates = icrc30.revoke_token(tokenOwner, {token_ids=tokenIdsWithDuplicates; spender=?spender; from_subaccount=null; created_at_time=null; memo=null;});
let revocationResponsesEmpty = icrc30.revoke_token(tokenOwner, {token_ids=emptyTokenIds; spender=?spender; from_subaccount=null; created_at_time=null; memo=null;});

D.print("Revocation responses" # debug_show(revocationResponsesWithDuplicates, revocationResponsesEmpty));
});
Expand Down

0 comments on commit 1e70d7b

Please sign in to comment.