Skip to content

Commit

Permalink
add automation test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacqueline Zhang committed Mar 14, 2024
1 parent 0e49232 commit 1242f4e
Show file tree
Hide file tree
Showing 13 changed files with 448 additions and 609 deletions.
14 changes: 5 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
TEST_WALLET_A_ADDRESS = 0x0000000000000000000000000000000000000000
TEST_WALLET_B_ADDRESS = 0x0000000000000000000000000000000000000000
TEST_WALLET_C_ADDRESS = 0x0000000000000000000000000000000000000000
PRIVATE_KEYS = privateKey1,privateKey2,privateKey3
NFT_CONTRACT_ADDRESS = 0x0000000000000000000000000000000000000000
RPC_URL = https://rpc.ankr.com/eth_sepolia
LICENSE_MODULE = 0x0000000000000000000000000000000000000000
MINT_FEE_TOKEN = 0x0000000000000000000000000000000000000000
ROYALTY_POLICY = 0x0000000000000000000000000000000000000000
RPC_PROVIDER_URL=https://rpc.ankr.com/eth_sepolia
WALLET_PRIVATE_KEY_A=0x0000000000000000000000000000000000000000
WALLET_PRIVATE_KEY_B=0x0000000000000000000000000000000000000000
WALLET_PRIVATE_KEY_C=0x0000000000000000000000000000000000000000
MY_NFT_CONTRACT_ADDRESS=0x0000000000000000000000000000000000000000
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pnpm-debug.log*
lerna-debug.log*

node_modules
mochawesome-report
dist
dist-ssr
*.local
Expand All @@ -23,3 +24,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
package-lock.json
10 changes: 4 additions & 6 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ This project dedicates to perform e2e test for the story protocol typescript sdk

- Run specific test (recommend):

run `npm run test:flow1`
run `mocha -r ts-node/register -r mocha-steps ./test/**/**/*.test.ts --timeout 240000`

- Run all test together:

run `npm run test`

## How can I extend test flows to this project
- Run all test together:

run `npm run open:report`

- wrap your test flow into a function and default export this function.
- put the new test file into `/test/e2e/flows`
- import the function from `/test/e2e/e2e.ts`, and register it into `flowsTestMap`
- extend the `scripts` field of the `/package.json` file with a reference to the existing other scrip command, and finally add the flow name to `TEST_FLOWS` in 'test' of the 'scripts'
234 changes: 0 additions & 234 deletions abi/mintNFT.json

This file was deleted.

61 changes: 16 additions & 45 deletions config/config.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,25 @@
import "dotenv/config";
import {
Hex,
createWalletClient,
http,
PrivateKeyAccount,
} from "viem";
import { Hex, http, Address } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { StoryClient, StoryConfig } from "@story-protocol/core-sdk";

import { sepolia } from "viem/chains";

export const getStoryConfig = (account: PrivateKeyAccount) => ({
transport: http(RPC_URL),
account,
}) as StoryConfig;
export const transport = http(process.env.RPC_PROVIDER_URL);
export const privateKeyA = process.env.WALLET_PRIVATE_KEY_A as Hex;
export const privateKeyB = process.env.WALLET_PRIVATE_KEY_B as Hex;

export const TOKEN_CONTRACT_ADDRESS = "0x7ee32b8B515dEE0Ba2F25f612A04a731eEc24F49";
export const TEST_WALLET_A_ADDRESS = (process.env.TEST_WALLET_A_ADDRESS || "0x") as `0x${string}`;
export const TEST_WALLET_B_ADDRESS = (process.env.TEST_WALLET_B_ADDRESS || "0x") as `0x${string}`;
export const TEST_WALLET_C_ADDRESS = (process.env.TEST_WALLET_C_ADDRESS || "0x") as `0x${string}`;
export const NFT_CONTRACT_ADDRESS = (process.env.NFT_CONTRACT_ADDRESS || "0x") as `0x${string}`;
export const RPC_URL = process.env.RPC_URL || "";
export const LICENSE_MODULE = (process.env.LICENSE_MODULE || "") as `0x${string}`;
export const MINT_FEE_TOKEN = (process.env.MINT_FEE_TOKEN || "") as `0x${string}`;
export const ROYALTY_POLICY = (process.env.ROYALTY_POLICY || "") as `0x${string}`;
export const accountA = privateKeyToAccount(privateKeyA as Address);
export const accountB = privateKeyToAccount(privateKeyB as Address);

export const accountA = privateKeyToAccount((process.env.PRIVATE_KEYS?.split(',')[0] || '0x') as Hex);
export const accountB = privateKeyToAccount((process.env.PRIVATE_KEYS?.split(',')[1] || '0x') as Hex);
export const accountC = privateKeyToAccount((process.env.PRIVATE_KEYS?.split(',')[2] || '0x') as Hex);

const configA: StoryConfig = getStoryConfig(accountA);
const configB: StoryConfig = getStoryConfig(accountB);
const configC: StoryConfig = getStoryConfig(accountC);

export const storyClientA: StoryClient = StoryClient.newClient(configA);
export const storyClientB: StoryClient = StoryClient.newClient(configB);
export const storyClientC: StoryClient = StoryClient.newClient(configC);

export const walletClientA = createWalletClient({
transport: http(RPC_URL),
chain: sepolia,
export const configA: StoryConfig = {
account: accountA,
});
export const walletClientB = createWalletClient({
transport: http(RPC_URL),
chain: sepolia,
transport: transport,
}

export const configB: StoryConfig = {
account: accountB,
});
export const walletClientC = createWalletClient({
transport: http(RPC_URL),
chain: sepolia,
account: accountC,
});
transport: transport,
}

export const clientA = StoryClient.newClient(configA)
export const clientB = StoryClient.newClient(configB)
Loading

0 comments on commit 1242f4e

Please sign in to comment.