Skip to content

Feature/lit 3580 refactor js sdk change all enums to constants #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tinny ENV Vars
MAX_ATTEMTPS=1
NETWORK=localchain
NETWORK=custom
DEBUG=true
WAIT_FOR_KEY_INTERVAL=3000
TIME_TO_RELEASE_KEY=10000
Expand All @@ -16,4 +16,4 @@ STOP_TESTNET=false
TESTNET_MANAGER_URL=http://127.0.0.1:8000
USE_LIT_BINARIES=true
LIT_NODE_BINARY_PATH=/usr/bin/lit_node
LIT_ACTION_BINARY_PATH=/usr/bin/lit_actions
LIT_ACTION_BINARY_PATH=/usr/bin/lit_actions
12 changes: 6 additions & 6 deletions local-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tinny is a mini test framework, serving as a temporary solution for running e2e
# Prerequisite

- Node v20 or above
- The generated file `networkContext.ts` after running `npm run deploy -- --network localchain` in the `lit-assets` repo
- The generated file `networkContext.ts` after running `npm run deploy -- --network custom` in the `lit-assets` repo

# How to run

Expand All @@ -16,8 +16,8 @@ The `testName` specified in the filter **must be the same as the function name**
## to run all tests

```
// run all tests on localchain
DEBUG=true NETWORK=localchain yarn test:local
// run all tests on local chain
DEBUG=true NETWORK=custom yarn test:local

// run filtered tests on manzano
DEBUG=true NETWORK=manzano yarn test:local --filter=testExample
Expand All @@ -41,7 +41,7 @@ Below is the API documentation for the `ProcessEnvs` interface, detailing the co
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MAX_ATTEMPTS` | Each test is executed in a loop with a maximum number of attempts specified by `devEnv.processEnvs.MAX_ATTEMPTS`. |
| `TEST_TIMEOUT` | The maximum number of milliseconds to wait for a test to complete. |
| `NETWORK` | The network to use for testing, which can be one of the following: `LIT_TESTNET.LOCALCHAIN`, `LIT_TESTNET.MANZANO`, or `LIT_TESTNET.CAYENNE`. |
| `NETWORK` | The network to use for testing, which can be one of the following: `LIT_NETWORK.Custom`, `LIT_NETWORK.Manzano`, or `LIT_NETWORK.Cayenne`. |
| `DEBUG` | Specifies whether to enable debug mode. |
| `REQUEST_PER_KILOSECOND` | To execute a transaction with Lit, you must reserve capacity on the network using Capacity Credits. These allow a set number of requests over a period (default 2 days). |
| `WAIT_FOR_KEY_INTERVAL` | Wait time in milliseconds if no private keys are available. |
Expand All @@ -50,7 +50,7 @@ Below is the API documentation for the `ProcessEnvs` interface, detailing the co
| `RUN_IN_BAND_INTERVAL` | The interval in milliseconds to run the tests in a single thread. |
| `LIT_RPC_URL` | The URL of the Lit RPC server: <br> - For local Anvil: `http://127.0.0.1:8545` <br> - For Chronicle: `https://chain-rpc.litprotocol.com/http` <br> - For Yellowstone: `https://yellowstone-rpc.litprotocol.com` |
| `STOP_TESTNET` | Flag to stop a single running testnet after the test run concludes. |
| `USE_SHIVA` | A flag to determine if `Shiva` should be used for the `localchain` network. |
| `USE_SHIVA` | A flag to determine if `Shiva` should be used for the local `custom` network. |
| `PRIVATE_KEYS` | A set of private keys to use which will be used to perform chain operations. |
| `CHUNK_SIZE` | Determines the number of tests run concurrently during parallel execution |

Expand All @@ -77,7 +77,7 @@ export const testExample = async (devEnv: TinnyEnvironment) => {

// ========== Enviorment ==========
// This test will be skipped if we are testing on the Cayenne network
devEnv.setUnavailable(LIT_TESTNET.CAYENNE);
devEnv.setUnavailable(LIT_NETWORK.Cayenne);

// Using litNodeClient
const res = await devEnv.litNodeClient.executeJs({...});
Expand Down
14 changes: 8 additions & 6 deletions local-tests/setup/session-sigs/get-eoa-session-sigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import {
import {
AuthCallbackParams,
AuthSig,
LitAbility,
LitResourceAbilityRequest,
} from '@lit-protocol/types';
import { log } from '@lit-protocol/misc';
import { ethers } from 'ethers';
import { CENTRALISATION_BY_NETWORK, LitNetwork } from '@lit-protocol/constants';
import {
LIT_ABILITY,
CENTRALISATION_BY_NETWORK,
} from '@lit-protocol/constants';
import { TinnyPerson } from '../tinny-person';
import { TinnyEnvironment } from '../tinny-environment';

Expand Down Expand Up @@ -42,11 +44,11 @@ export const getEoaSessionSigs = async (
const _resourceAbilityRequests = resourceAbilityRequests || [
{
resource: new LitPKPResource('*'),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
{
resource: new LitActionResource('*'),
ability: LitAbility.LitActionExecution,
ability: LIT_ABILITY.LitActionExecution,
},
];

Expand Down Expand Up @@ -118,11 +120,11 @@ export const getEoaSessionSigsWithCapacityDelegations = async (
resourceAbilityRequests: [
{
resource: new LitPKPResource('*'),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
{
resource: new LitActionResource('*'),
ability: LitAbility.LitActionExecution,
ability: LIT_ABILITY.LitActionExecution,
},
],
authNeededCallback: async ({
Expand Down
19 changes: 11 additions & 8 deletions local-tests/setup/session-sigs/get-lit-action-session-sigs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { LitActionResource, LitPKPResource } from '@lit-protocol/auth-helpers';
import { LitAbility, LitResourceAbilityRequest } from '@lit-protocol/types';
import { CENTRALISATION_BY_NETWORK, LitNetwork } from '@lit-protocol/constants';
import { LitResourceAbilityRequest } from '@lit-protocol/types';
import {
LIT_ABILITY,
CENTRALISATION_BY_NETWORK,
} from '@lit-protocol/constants';
import { TinnyPerson } from '../tinny-person';
import { TinnyEnvironment } from '../tinny-environment';

Expand Down Expand Up @@ -49,11 +52,11 @@ export const getLitActionSessionSigs = async (
const _resourceAbilityRequests = resourceAbilityRequests || [
{
resource: new LitPKPResource('*'),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
{
resource: new LitActionResource('*'),
ability: LitAbility.LitActionExecution,
ability: LIT_ABILITY.LitActionExecution,
},
];

Expand Down Expand Up @@ -96,11 +99,11 @@ export const getLitActionSessionSigsUsingIpfsId = async (
const _resourceAbilityRequests = resourceAbilityRequests || [
{
resource: new LitPKPResource('*'),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
{
resource: new LitActionResource('*'),
ability: LitAbility.LitActionExecution,
ability: LIT_ABILITY.LitActionExecution,
},
];

Expand Down Expand Up @@ -132,7 +135,7 @@ export const getInvalidLitActionSessionSigs = async (
resourceAbilityRequests: [
{
resource: new LitPKPResource('*'),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
],
litActionCode: Buffer.from(INVALID_SESSION_SIG_LIT_ACTION_CODE).toString(
Expand All @@ -157,7 +160,7 @@ export const getInvalidLitActionIpfsSessionSigs = async (
resourceAbilityRequests: [
{
resource: new LitPKPResource('*'),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
],
litActionIpfsId: INVALID_IPFS_ID,
Expand Down
11 changes: 7 additions & 4 deletions local-tests/setup/session-sigs/get-pkp-session-sigs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { LitActionResource, LitPKPResource } from '@lit-protocol/auth-helpers';
import { LitAbility, LitResourceAbilityRequest } from '@lit-protocol/types';
import { LitResourceAbilityRequest } from '@lit-protocol/types';
import { log } from '@lit-protocol/misc';
import { CENTRALISATION_BY_NETWORK, LitNetwork } from '@lit-protocol/constants';
import {
LIT_ABILITY,
CENTRALISATION_BY_NETWORK,
} from '@lit-protocol/constants';
import { TinnyEnvironment } from '../tinny-environment';
import { TinnyPerson } from '../tinny-person';

Expand All @@ -24,11 +27,11 @@ export const getPkpSessionSigs = async (
const _resourceAbilityRequests = resourceAbilityRequests || [
{
resource: new LitPKPResource('*'),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
{
resource: new LitActionResource('*'),
ability: LitAbility.LitActionExecution,
ability: LIT_ABILITY.LitActionExecution,
},
];

Expand Down
6 changes: 3 additions & 3 deletions local-tests/setup/shiva-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class ShivaError extends Error {

export interface ShivaEnvs {
/**
* If runnnig no localchain this flag will stop the running testnet when the test
* If running on local chain this flag will stop the running testnet when the test
* run has finished. Which is when all pending task promises have settled.
*/
STOP_TESTNET: boolean;

/**
* URL for Testnet manager intigration
* URL for Testnet manager integration
*/
TESTNET_MANAGER_URL: string;

Expand Down Expand Up @@ -57,7 +57,7 @@ export interface ShivaEnvs {

/**
* Client implementation for a single testnet instance managed by the Shiva tool
* Is essentially a localchain setup but allows for programmatic operations to be performed
* Is essentially a local chain setup but allows for programmatic operations to be performed
* on the network from the implementation within this class. Each testnet is a unique network
*/
export class TestnetClient {
Expand Down
40 changes: 7 additions & 33 deletions local-tests/setup/tinny-config.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
import { LIT_NETWORK_VALUES } from '@lit-protocol/constants';
import { LitNodeClient } from '@lit-protocol/lit-node-client';
import { LitContractResolverContext } from '@lit-protocol/types';

export enum LIT_TESTNET {
LOCALCHAIN = 'localchain',
MANZANO = 'manzano',
CAYENNE = 'cayenne',
DATIL_DEV = 'datil-dev',
DATIL_TEST = 'datil-test',
DATIL_PROD = 'datil',
}

export enum LIT_RPC {
LOCAL_ANVIL = 'http://127.0.0.1:8545',
CHRONICLE = 'https://chain-rpc.litprotocol.com/http',
YELLOWSTONE = 'https://yellowstone-rpc.litprotocol.com',
}

/**
* Mapping of testnet names to corresponding RPC endpoints.
*/
export const RPC_MAP = {
[LIT_TESTNET.LOCALCHAIN]: LIT_RPC.LOCAL_ANVIL,
[LIT_TESTNET.MANZANO]: LIT_RPC.CHRONICLE,
[LIT_TESTNET.CAYENNE]: LIT_RPC.CHRONICLE,
[LIT_TESTNET.DATIL_DEV]: LIT_RPC.YELLOWSTONE,
[LIT_TESTNET.DATIL_TEST]: LIT_RPC.YELLOWSTONE,
[LIT_TESTNET.DATIL_PROD]: LIT_RPC.YELLOWSTONE,
};

/**
* Represents the configuration options for the process environment.
*/
Expand All @@ -44,12 +18,12 @@ export interface ProcessEnvs {

/**
* The network to use for testing. This can be one of the following:
* - `LIT_TESTNET.LOCALCHAIN`
* - `LIT_TESTNET.MANZANO`
* - `LIT_TESTNET.CAYENNE`
* - `LIT_TESTNET.DATIL_DEV`
* - `LIT_NETWORK.Custom`
* - `LIT_NETWORK.Manzano`
* - `LIT_NETWORK.Cayenne`
* - `LIT_NETWORK.DatilDev`
*/
NETWORK: LIT_TESTNET;
NETWORK: LIT_NETWORK_VALUES;

/**
* The number of milliseconds to wait between each request.
Expand Down Expand Up @@ -137,7 +111,7 @@ export type PKPInfo = {
export interface TinnyEnvConfig {
rpc: string;
litNodeClient: LitNodeClient;
network: LIT_TESTNET;
network: LIT_NETWORK_VALUES;
processEnvs: ProcessEnvs;
contractContext?: LitContractResolverContext;
}
Loading
Loading