Skip to content

Commit

Permalink
Merge pull request #21 from ixofoundation/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Michael-Ixo authored Mar 10, 2023
2 parents 4d95b9a + ef20ebb commit 29d1821
Show file tree
Hide file tree
Showing 263 changed files with 2,310 additions and 18,739 deletions.
100 changes: 58 additions & 42 deletions __tests__/flows/claims.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,86 @@
import { testMsg, utils } from "../helpers/common";
import * as Claims from "../modules/Claims";
import * as Cosmos from "../modules/Cosmos";
import * as Entity from "../modules/Entity";
import { WalletUsers } from "../helpers/constants";

export const claimsBasic = () =>
describe("Testing the Claims module", () => {
// Create protocol
let protocol = "did:ixo:entity:eaff254f2fc62aefca0d831bc7361c14";
// testMsg("/ixo.entity.v1beta1.MsgCreateEntity protocol", async () => {
// const res = await Entity.CreateEntity(
// "protocol",
// undefined,
// WalletUsers.charlie
// );
// protocol = utils.common.getValueFromEvents(res, "wasm", "token_id");
// console.log({ protocol });
// return res;
// });
// get from entity creation rawLog below
let adminAccount = "ixo1kqmtxkggcqa9u34lnr6shy0euvclgatw4f9zz5";
// testMsg(
// "/ixo.entity.v1beta1.MsgCreateEntity protocol",
// async () => {
// const res = await Entity.CreateEntity(
// "protocol",
// undefined,
// WalletUsers.charlie
// );
// protocol = utils.common.getValueFromEvents(res, "wasm", "token_id");
// console.log({ protocol });
// return res;
// },
// true
// );

// helper to send funds to an admin account
// testMsg("test Bank Send to admin account", () =>
// Cosmos.BankSendTrx(100000000, WalletUsers.tester, undefined, adminAccount)
// );

// check the rawLog from below test to get collectionId
let collectionId = "1";
// testMsg("/ixo.claims.v1beta1.MsgCreateCollection", async () => {
// const res = await Claims.CreateCollection(protocol, protocol);
// console.log(res.rawLog);
// return res;
// });
// testMsg(
// "/ixo.claims.v1beta1.MsgCreateCollection",
// () => Claims.CreateCollection(protocol, protocol, adminAccount),
// true
// );

let claimId = "1";
// testMsg("/ixo.claims.v1beta1.MsgSubmitClaim", async () => {
// const res = await Claims.SubmitClaim(claimId, collectionId);
// console.log(res.rawLog);
// return res;
// });

// testMsg("/ixo.claims.v1beta1.MsgEvaluateClaim", async () => {
// const res = await Claims.EvaluateClaim(claimId, collectionId);
// console.log(res.rawLog);
// return res;
// });

// testMsg("/ixo.claims.v1beta1.MsgDisputeClaim", () =>
// Claims.DisputeClaim(claimId, "proof1")
// );

// testMsg("/ixo.claims.v1beta1.MsgWithdrawPayment", () =>
// Claims.WithdrawPayment(claimId)
// testMsg(
// "/ixo.entity.v1beta1.MsgGrantEntityAccountAuthz agent submit",
// () =>
// Claims.GrantEntityAccountClaimsSubmitAuthz(
// protocol,
// "admin",
// adminAccount,
// collectionId,
// 10
// ),
// true
// );

// testMsg("/cosmos.authz.v1beta1.MsgGrant agent submit", () =>
// Claims.MsgGrantAgentSubmit(collectionId, 10)
// testMsg("/cosmos.authz.v1beta1.MsgExec agent submit", () =>
// Claims.MsgExecAgentSubmit(claimId, collectionId, adminAccount)
// );

// testMsg("/cosmos.authz.v1beta1.MsgExec agent submit", async () => {
// const res = await Claims.MsgExecAgentSubmit(claimId, collectionId);
// console.log(res.rawLog);
// return res;
// });

// testMsg("/cosmos.authz.v1beta1.MsgGrant agent evaluate", () =>
// Claims.MsgGrantAgentEvaluate(collectionId, [], 10)
// testMsg(
// "/ixo.entity.v1beta1.MsgGrantEntityAccountAuthz agent evaluate",
// () =>
// Claims.GrantEntityAccountClaimsEvaluateAuthz(
// protocol,
// "admin",
// adminAccount,
// collectionId,
// [],
// 10
// ),
// true
// );

// testMsg("/cosmos.authz.v1beta1.MsgExec agent evaluate", () =>
// Claims.MsgExecAgentEvaluate(claimId, collectionId)
// testMsg(
// "/cosmos.authz.v1beta1.MsgExec agent evaluate",
// () => Claims.MsgExecAgentEvaluate(claimId, collectionId, adminAccount),
// true
// );

// testMsg("/cosmos.authz.v1beta1.MsgExec withdraw payment", () =>
// Claims.MsgExecWithdrawal(claimId)
// Claims.MsgExecWithdrawal(claimId, adminAccount)
// );
});
27 changes: 8 additions & 19 deletions __tests__/flows/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { WalletUsers } from "../helpers/constants";

export const bankBasic = () =>
describe("Testing the cosmos bank module", () => {
testMsg("/cosmos.bank.v1beta1.MsgSend", async () => {
const res = await Cosmos.BankSendTrx();
// console.log(res);
return res;
});
testMsg("/cosmos.bank.v1beta1.MsgSend", () =>
Cosmos.BankSendTrx(undefined, WalletUsers.tester, WalletUsers.oracle)
);
});

export const authzBasic = () =>
Expand All @@ -21,25 +19,16 @@ export const authzBasic = () =>
});

// quick helper to send funds to an address
// testMsg("test Bank Send", async () => {
// const res = await Cosmos.BankSendTrx(
// testMsg("test Bank Send", () =>
// Cosmos.BankSendTrx(
// 1000000000,
// WalletUsers.tester,
// undefined,
// "ixo1syjk0qh59vxz3zk776m5vrzvyv4nwpvh57yps2"
// );
// console.log(res);
// return res;
// });
// )
// );

testMsg("test Exec Send", async () => {
const res = await Authz.MsgExecSend(
1000000,
"ixo1syjk0qh59vxz3zk776m5vrzvyv4nwpvh57yps2"
);
console.log(res);
return res;
});
testMsg("test Exec Send", () => Authz.MsgExecSend(1000000));
});

export const sendTokens = () =>
Expand Down
9 changes: 3 additions & 6 deletions __tests__/flows/cosmwasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const wasmBasic = () =>
const msg = { minter: tester };

const res = await Wasm.WasmInstantiateTrx(2, JSON.stringify(msg));
console.log({ res });
contractAddress = utils.common.getValueFromEvents(
res,
"instantiate",
Expand Down Expand Up @@ -72,10 +71,9 @@ export const wasmBasic = () =>
JSON.stringify(msg),
WalletUsers.tester
);
console.log(res);
console.log(JSON.parse(res.rawLog!)[0].events);
return res;
});
}),
true;

test("query wasm state", async () => {
const tester = (await getUser().getAccounts())[0].address;
Expand Down Expand Up @@ -107,9 +105,8 @@ export const wasmBasic = () =>
// const msg = { minter: tester };

// const res = await Wasm.WasmStoreTrx();
// console.log({ res });
// return res;
// });
// }, true );
});

export const daoDaoContracts = () =>
Expand Down
22 changes: 12 additions & 10 deletions __tests__/flows/entities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CellnodeWeb3Resource } from "../../src/custom_queries/cellnode";
import {
customQueries,
getFileFromPath,
Expand All @@ -20,9 +19,9 @@ export const enititiesBasic = () =>
return res;
});

// testMsg("/ixo.entity.v1beta1.MsgUpdateEntityVerified", () =>
// Entity.UpdateEntityVerified(undefined, entityDid)
// );
testMsg("/ixo.entity.v1beta1.MsgUpdateEntityVerified", () =>
Entity.UpdateEntityVerified(undefined, entityDid)
);

// testMsg("/ixo.entity.v1beta1.MsgTransferEntity", () =>
// Entity.TransferEntity(undefined, entityDid)
Expand All @@ -43,14 +42,17 @@ export const enititiesBasic = () =>
return res;
});

testMsg("/ixo.entity.v1beta1.MsgGrantEntityAccountAuthz", async () => {
const res = await Entity.GrantEntityAccountAuthz(entityDid, name);
console.log(res);
return res;
});
testMsg(
"/ixo.entity.v1beta1.MsgGrantEntityAccountAuthz",
() => Entity.GrantEntityAccountAuthz(entityDid, name),
true
);
});

export const supamotoFlow = () =>
// ------------------------------------------------------------
// flow to run after devnet was reset, please dont change
// ------------------------------------------------------------
export const supamotoEntities = () =>
describe("Testing the Supamoto nfts flow", () => {
const cellNodeNetwork = "devnet";

Expand Down
98 changes: 54 additions & 44 deletions __tests__/flows/iids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const registerIids = () =>
const users = Object.values(WalletUsers).filter(
(user) =>
![
"project",
"bond",
"oracle",
"random",
Expand All @@ -49,52 +48,63 @@ export const registerIids = () =>
// );
});

// ------------------------------------------------------------
// flow to run after devnet was reset, please dont change
// ------------------------------------------------------------
export const registerIidsDev = () =>
describe("Testing the faucet and creation of Iids for dev", () => {
const users = Object.values(WalletUsers).filter(
(user) => !["bond", "oracle", "random"].includes(user)
);

users.forEach((user) => {
sendFromFaucet(user);
testMsg("/ixo.iid.v1beta1.MsgCreateIidDocument", () =>
Iid.CreateIidDoc(user)
);
});
});

export const iidsBasic = () =>
describe("Testing the Iid module", () => {
// testMsg("/ixo.iid.v1beta1.MsgUpdateIidDocument", () => Iid.UpdateIidDoc());
testMsg("/ixo.iid.v1beta1.MsgAddIidContext", async () => {
const res = await Iid.AddIidContext();
console.log(res);
return res;
});
// testMsg("/ixo.iid.v1beta1.MsgDeleteIidContext", () =>
// Iid.DeleteIidContext()
// );
// testMsg("/ixo.iid.v1beta1.MsgAddVerification", () => Iid.AddVerification());
// testMsg("/ixo.iid.v1beta1.MsgSetVerificationRelationships", () =>
// Iid.SetVerificationRelationships()
// );
// testMsg("/ixo.iid.v1beta1.MsgRevokeVerification", () =>
// Iid.RevokeVerification()
// );
// testMsg("/ixo.iid.v1beta1.MsgAddAccordedRight", () =>
// Iid.AddAccordedRight()
// );
// testMsg("/ixo.iid.v1beta1.MsgDeleteAccordedRight", () =>
// Iid.DeleteAccordedRight()
// );
// testMsg("/ixo.iid.v1beta1.MsgAddController", () => Iid.AddController());
// testMsg("/ixo.iid.v1beta1.MsgDeleteController", () =>
// Iid.DeleteController()
// );
// testMsg("/ixo.iid.v1beta1.MsgAddLinkedEntity", () => Iid.AddLinkedEntity());
// testMsg("/ixo.iid.v1beta1.MsgDeleteLinkedEntity", () =>
// Iid.DeleteLinkedEntity()
// );
// testMsg("/ixo.iid.v1beta1.MsgAddLinkedResource", () =>
// Iid.AddLinkedResource()
// );
// testMsg("/ixo.iid.v1beta1.MsgDeleteLinkedResource", () =>
// Iid.DeleteLinkedResource()
// );
// testMsg("/ixo.iid.v1beta1.MsgAddLinkedClaim", () =>
// Iid.AddLinkedClaim()
// );
// testMsg("/ixo.iid.v1beta1.MsgDeleteLinkedClaim", () =>
// Iid.DeleteLinkedClaim()
// );
// testMsg("/ixo.iid.v1beta1.MsgAddService", () => Iid.AddService());
// testMsg("/ixo.iid.v1beta1.MsgDeleteService", () => Iid.DeleteService());
testMsg("/ixo.iid.v1beta1.MsgAddIidContext", () => Iid.AddIidContext());
testMsg("/ixo.iid.v1beta1.MsgDeleteIidContext", () =>
Iid.DeleteIidContext()
);
testMsg("/ixo.iid.v1beta1.MsgAddVerification", () => Iid.AddVerification());
testMsg("/ixo.iid.v1beta1.MsgSetVerificationRelationships", () =>
Iid.SetVerificationRelationships()
);
testMsg("/ixo.iid.v1beta1.MsgRevokeVerification", () =>
Iid.RevokeVerification()
);
testMsg("/ixo.iid.v1beta1.MsgAddAccordedRight", () =>
Iid.AddAccordedRight()
);
testMsg("/ixo.iid.v1beta1.MsgDeleteAccordedRight", () =>
Iid.DeleteAccordedRight()
);
testMsg("/ixo.iid.v1beta1.MsgAddController", () => Iid.AddController());
testMsg("/ixo.iid.v1beta1.MsgDeleteController", () =>
Iid.DeleteController()
);
testMsg("/ixo.iid.v1beta1.MsgAddLinkedEntity", () => Iid.AddLinkedEntity());
testMsg("/ixo.iid.v1beta1.MsgDeleteLinkedEntity", () =>
Iid.DeleteLinkedEntity()
);
testMsg("/ixo.iid.v1beta1.MsgAddLinkedResource", () =>
Iid.AddLinkedResource()
);
testMsg("/ixo.iid.v1beta1.MsgDeleteLinkedResource", () =>
Iid.DeleteLinkedResource()
);
testMsg("/ixo.iid.v1beta1.MsgAddLinkedClaim", () => Iid.AddLinkedClaim());
testMsg("/ixo.iid.v1beta1.MsgDeleteLinkedClaim", () =>
Iid.DeleteLinkedClaim()
);
testMsg("/ixo.iid.v1beta1.MsgAddService", () => Iid.AddService());
testMsg("/ixo.iid.v1beta1.MsgDeleteService", () => Iid.DeleteService());
});

export const generateBlockchainTestUsers = () => {
Expand Down
Loading

0 comments on commit 29d1821

Please sign in to comment.