Skip to content

Commit

Permalink
test end to end ok
Browse files Browse the repository at this point in the history
  • Loading branch information
MSghais committed Jun 18, 2024
1 parent e998a22 commit 39efb39
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 30 deletions.
1 change: 1 addition & 0 deletions prototype/.env.exemple
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:$
NOSTR_RELAYER_WEBSOCKET=ws://localhost:3000

ESCROW_CLASS_HASH=0x3f70abaaeef59cc900b597d45a2c97c08abb5260c03327cce9e45d4c7a8ad0 # Sepolia
REDECLARE_ACCOUNT=false # Set to true on devnet
5 changes: 3 additions & 2 deletions prototype/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export const ACCOUNT_TEST_PROFILE = {
"0x1b5f5bee60ce25d6979c5b88cfbb74ad1dae197dba11719b2e06a5efa7e666d",
},
escrow: {
contract: "0x53327953bddcb4ae216b14ea0b84261c6c1ad0af112a29be2dab11cf2e76c48",
SEPOLIA: "0x53327953bddcb4ae216b14ea0b84261c6c1ad0af112a29be2dab11cf2e76c48"
contract:"0x2d8281937c8f815a53ae4d02252154b225f87973ec96d3f08bdd624bf6e685d"
// contract: "0x53327953bddcb4ae216b14ea0b84261c6c1ad0af112a29be2dab11cf2e76c48",
// SEPOLIA: "0x53327953bddcb4ae216b14ea0b84261c6c1ad0af112a29be2dab11cf2e76c48"
}
};
export const ERROR_MESSAGES = {
Expand Down
32 changes: 16 additions & 16 deletions prototype/test/escrow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ dotenv.config();
*/
// Sepolia params testing
const currentId = 1
// const idToClaim = 1
const idToClaim = 1

const idToCancel = 1
let escrow_address = ACCOUNT_TEST_PROFILE.escrow.contract // change default address
let escrow_address:string|undefined = ACCOUNT_TEST_PROFILE.escrow.contract // change default address
let token_used_address = TOKENS_ADDRESS.DEVNET.ETH;

describe("Escrow End to end test", () => {
Expand All @@ -38,6 +40,10 @@ describe("Escrow End to end test", () => {
let escrowContract = await createEscrowAccount();

console.log("escrow address", escrowContract?.contract_address)

if(escrowContract?.contract_address) {
escrow_address=escrowContract?.contract_address
}
escrow = await prepareAndConnectContract(
escrowContract?.contract_address ?? ACCOUNT_TEST_PROFILE?.escrow?.contract, // uncomment if you recreate a contract
account
Expand All @@ -57,20 +63,10 @@ describe("Escrow End to end test", () => {
const account = new Account(provider, accountAddress0, privateKey0, "1");
const alicePublicKey = ACCOUNT_TEST_PROFILE?.alice?.nostrPublicKey;

let escrow;
if (process.env.IS_DEPLOY_CONTRACT == "true") {
let escrowContract = await createEscrowAccount();

escrow = await prepareAndConnectContract(
escrowContract?.contract_address ?? ACCOUNT_TEST_PROFILE?.escrow?.contract, // uncomment if you recreate a contract
account
);
} else {
escrow = await prepareAndConnectContract(
escrow_address ?? ACCOUNT_TEST_PROFILE?.escrow?.contract,
account
);
}
let escrow = await prepareAndConnectContract(
escrow_address ?? ACCOUNT_TEST_PROFILE?.escrow?.contract,
account
);

/** Send a note */
let amount: number = 1;
Expand Down Expand Up @@ -131,9 +127,13 @@ describe("Escrow End to end test", () => {
}
/** Claim */
let timestamp = 1716285235;


let depositToClaim = await escrow.get_deposit(idToClaim)
console.log("deposit to claim",depositToClaim)
// let timestamp = new Date().getTime();

let content = `claim ${cairo.felt(currentId)}`;
let content = `claim ${cairo.felt(idToClaim)}`;
let txClaim = await claimDeposit({
escrow,
account,
Expand Down
26 changes: 14 additions & 12 deletions prototype/utils/escrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,21 @@ export const createEscrowAccount = async () => {
// const AAaccount = new Account(provider, AAcontractAddress, AAprivateKey);
/** @description uncomment this to declare your account */
// console.log("declare account");
console.log("try declare account");
const declareResponse = await account0.declare({
contract: compiledSierraAAaccount,
casm: compiledAACasm,
});
console.log("Declare deploy", declareResponse?.transaction_hash);
await provider.waitForTransaction(declareResponse?.transaction_hash);
const contractClassHash = declareResponse.class_hash;
EscrowClassHash = contractClassHash;


const nonce = await account0?.getNonce();
console.log("nonce", nonce);
if(process.env.REDECLARE_ACCOUNT) {
console.log("try declare account");
const declareResponse = await account0.declare({
contract: compiledSierraAAaccount,
casm: compiledAACasm,
});
console.log("Declare deploy", declareResponse?.transaction_hash);
await provider.waitForTransaction(declareResponse?.transaction_hash);
const contractClassHash = declareResponse.class_hash;
EscrowClassHash = contractClassHash;

const nonce = await account0?.getNonce();
console.log("nonce", nonce);
}

const { transaction_hash, contract_address } =
await account0.deployContract({
Expand Down

0 comments on commit 39efb39

Please sign in to comment.