Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
44007d1
feat: Update dependencies and add React testing setup
chiranjeev13 Nov 13, 2025
6d85079
feat: Introduce IncoTest react component and related functionality
chiranjeev13 Nov 13, 2025
a9e4866
chore: remove unused file
chiranjeev13 Nov 13, 2025
83cdcde
chore: package scripts
chiranjeev13 Nov 13, 2025
82e71b4
chore: update dependencies and refactor testing setup
chiranjeev13 Nov 14, 2025
c6ac26e
chore: update test script to include frontend build
chiranjeev13 Nov 14, 2025
d655c62
chore: update package dependencies to use workspace references
chiranjeev13 Nov 14, 2025
4f669c2
feat: Enhance IncoTest component and testing setup
chiranjeev13 Nov 16, 2025
ac9d6db
chore: restructure react-example testing setup and update dependencies
chiranjeev13 Nov 16, 2025
d3d483e
chore: downgrade React and React-DOM versions in bun.lock and package…
chiranjeev13 Nov 16, 2025
1e25ae9
chore: update React and related dependencies to latest versions in bu…
chiranjeev13 Nov 16, 2025
8d87037
Merge branch 'main' into cm/frontend-e2e
chiranjeev13 Dec 4, 2025
42d4522
chore: bun fixes
chiranjeev13 Dec 4, 2025
0e3f567
chore: update dependencies and testing setup for react-example
chiranjeev13 Dec 10, 2025
4a27f86
Merge branch 'main' into cm/frontend-e2e
chiranjeev13 Dec 10, 2025
f76bf35
chore: update Inco Lightning dependencies and Docker configuration
chiranjeev13 Dec 15, 2025
1aaa72f
fix: update IncoTest configuration to use devnet
chiranjeev13 Dec 15, 2025
7385d87
fix: update Inco encryption to use devnet for localNode connection
chiranjeev13 Dec 15, 2025
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# The version of the Inco Lightning test docker images to use
DOCKER_IMAGE_TAG=v0.7.0
DOCKER_IMAGE_TAG=v0.7.5
21 changes: 18 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
{
"name": "@inco/lightning-rod-test",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"test:e2e": "bun vitest run src/test/lightning.local.e2e.test.ts",
"test:frontend:build": "bun vitest run src/test/build-validation.test.ts",
"test:frontend": "pushd src/test/react-example && bun run test && popd",
"test:tsc": "tsc --noEmit",
"generate:abis": "bun wagmi generate"
},
"dependencies": {
"@inco/js": "workspace:*",
"viem": "^2.28.0"
"viem": "^2.28.0",
"webpack": "^5.102.1"
},
"devDependencies": {
"vitest": "^3.1.2",
"@wagmi/cli": "^2.2.1"
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react": "^4.4.1",
"@vitest/browser-playwright": "^4.0.8",
"@vitest/ui": "^4.0.8",
"@wagmi/cli": "^2.2.1",
"happy-dom": "^20.0.10",
"playwright": "^1.56.1",
"typescript": "~5.8.3",
"vitest": "^4.0.8",
"vitest-browser-react": "^2.0.2"
}
}
40 changes: 0 additions & 40 deletions backend/src/lib.ts

This file was deleted.

45 changes: 45 additions & 0 deletions backend/src/test/build-validation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// test/build-validation.test.ts
import { execSync } from 'child_process';
import { existsSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { describe, it } from 'vitest';

// ESM-compatible __dirname replacement
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

describe('React Example Build Validation', () => {
const reactExampleDir = join(__dirname, 'react-example');

it('should build the react-example without errors', async () => {
// Ensure dependencies are installed before building
const nodeModulesPath = join(reactExampleDir, 'node_modules');
if (!existsSync(nodeModulesPath)) {
console.log('Installing dependencies for react-example...');
execSync('bun install', {
cwd: reactExampleDir,
encoding: 'utf-8',
stdio: 'inherit',
env: {
...process.env,
},
});
}

try {
execSync('bun run build', {
cwd: reactExampleDir,
encoding: 'utf-8',
stdio: 'inherit',
env: {
...process.env,
NODE_ENV: 'production',
},
});
} catch (error: any) {
// Capture error output even with inherit
throw new Error(`Build failed: ${error.message}`);
}
}, 120000); // 2 minute timeout for build
});
8 changes: 3 additions & 5 deletions backend/src/test/lightning-addtwo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { beforeAll, describe, expect, it } from 'vitest';
import addTwoBuild from '../../../contracts/out/AddTwo.sol/AddTwo.json';
import { addTwoAbi } from '../generated/abis.js';
import { type E2EConfig, type E2EParams } from './lightning-test.js';
import { handleTypes } from '@inco/js';

export function runAddTwoE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EParams) {
const { walletClient, publicClient, incoLite } = params;
Expand Down Expand Up @@ -49,16 +50,14 @@ export function runAddTwoE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EParam
address: incoVerifierAddress,
client: publicClient,
});
const eciesKey = await incoVerifier.read.eciesPubkey();
const encryptor = zap.getEncryptor(eciesKey);

const inputCt = await zap.encrypt(
valueToAdd,
{
accountAddress: walletClient.account.address,
dappAddress,
handleType: handleTypes.euint256,
},
encryptor,
);
const { resultHandle } = await addTwo(dappAddress, inputCt, walletClient, publicClient, cfg);
console.log(`Result handle: ${resultHandle}`);
Expand All @@ -73,7 +72,6 @@ export function runAddTwoE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EParam
console.warn('###############################################');
console.warn(`# Step 3. Reencrypt the result handle`);
console.warn('###############################################');
console.warn(`# Using covalidator ${zap.covalidatorUrl}`);
// const reencryptor = await zap.getReencryptor(walletClient);
// const decrypted = await reencryptor({ handle: resultHandle });
// expect(decrypted.value).toBe(BigInt(valueToAdd + 2));
Expand Down Expand Up @@ -161,7 +159,7 @@ function prettifyInputCt(hex: HexString): string {
return `${hex.slice(0, 8)}...${hex.slice(-6)}`;
}

async function fundAccount(senderPrivKey: Hex, chain: Chain, hostChainRpcUrl: string) {
export async function fundAccount(senderPrivKey: Hex, chain: Chain, hostChainRpcUrl: string) {
const richAccount = privateKeyToAccount('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80');
const account = privateKeyToAccount(senderPrivKey);
const richWalletClient = createWalletClient({
Expand Down
35 changes: 13 additions & 22 deletions backend/src/test/lightning-libtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export function runLibTestE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EPara

describe('Lightning LibTest E2E', () => {
let libTestAddress: Address;
let encryptor: ReturnType<Lightning['getEncryptor']>;
let libTest: any;
let handleA: HexString;
let handleB: HexString;
Expand Down Expand Up @@ -99,8 +98,6 @@ export function runLibTestE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EPara
address: incoVerifierAddress,
client: publicClient,
});
const eciesKey = await incoVerifier.read.eciesPubkey();
encryptor = zap.getEncryptor(eciesKey);

libTest = getContract({
abi: libTestAbi,
Expand All @@ -115,8 +112,8 @@ export function runLibTestE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EPara
{
accountAddress: walletClient.account.address,
dappAddress: libTestAddress,
handleType: handleTypes.euint256,
},
encryptor,
);
const handleSim = await libTest.simulate.testNewEuint256([inputCt, walletClient.account.address], {
value: parseEther('0.0001'),
Expand All @@ -134,8 +131,8 @@ export function runLibTestE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EPara
{
accountAddress: walletClient.account.address,
dappAddress: libTestAddress,
handleType: handleTypes.ebool,
},
encryptor,
);
const handleSim = await libTest.simulate.testNewEbool([inputCt, walletClient.account.address], {
value: parseEther('0.0001'),
Expand All @@ -148,24 +145,18 @@ export function runLibTestE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EPara

// Helper function to create eaddress handle
async function createEaddressHandle(address: Address): Promise<HexString> {
const plaintext = {
scheme: encryptionSchemes.ecies,
type: handleTypes.euint160,
value: BigInt(address), // BigInt can parse hex strings directly, preserving precision
} as any;
const ct = await encryptor({
plaintext: plaintext,
context: {
hostChainId: BigInt(cfg.chain.id),
aclAddress: zap.executorAddress,
userAddress: walletClient.account.address,
contractAddress: libTestAddress,
const ct = await zap.encrypt(
BigInt(address),
{
accountAddress: walletClient.account.address,
dappAddress: libTestAddress,
handleType: handleTypes.euint160,
},
});
const handleSim = await libTest.simulate.testNewEaddress([ct.ciphertext.value, walletClient.account.address], {
);
const handleSim = await libTest.simulate.testNewEaddress([ct, walletClient.account.address], {
value: parseEther('0.0001'),
});
await libTest.write.testNewEaddress([ct.ciphertext.value, walletClient.account.address], {
await libTest.write.testNewEaddress([ct, walletClient.account.address], {
value: parseEther('0.0001'),
});
return handleSim.result as HexString;
Expand Down Expand Up @@ -385,7 +376,7 @@ export function runLibTestE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EPara

// Additional Bitwise Operations Tests
describe('Additional Bitwise Operations', () => {
it.skip('should test rotation left with stored handles', async () => {
it('should test rotation left with stored handles', async () => {
const sim = await libTest.simulate.testRotl([handleB, handleB]);
const txHash = await libTest.write.testRotl([handleB, handleB]);
await publicClient.waitForTransactionReceipt({ hash: txHash });
Expand All @@ -394,7 +385,7 @@ export function runLibTestE2ETest(zap: Lightning, cfg: E2EConfig,params: E2EPara
expect(value).toBe(BigInt(160));
}, 20_000);

it.skip('should test rotation right with stored handles', async () => {
it('should test rotation right with stored handles', async () => {
const sim = await libTest.simulate.testRotr([handleB, handleB]);
const txHash = await libTest.write.testRotr([handleB, handleB]);
await publicClient.waitForTransactionReceipt({ hash: txHash });
Expand Down
4 changes: 2 additions & 2 deletions backend/src/test/lightning.local.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Lightning } from '@inco/js/lite';
import { Hex } from 'viem';
import { anvil } from 'viem/chains';
import { describe } from 'vitest';
import { runE2ETest } from './lightning-test';
import { runE2ETest } from './lightning-test.js';

describe(`Lightning Local Node E2E`, { timeout: 50_000 }, async () => {
const zap = await Lightning.localNode('alphanet');
const zap = await Lightning.localNode('devnet');
runE2ETest(zap, {
chain: anvil,
senderPrivKey: zap.deployment.senderPrivateKey as Hex,
Expand Down
49 changes: 49 additions & 0 deletions backend/src/test/react-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "react-example",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "webpack --mode production",
"start": "webpack serve --mode development",
"test": "bun vitest run test/Inco.spec.tsx"
},
"dependencies": {
"@inco/js": "workspace:*",
"react": "latest",
"react-dom": "latest",
"viem": "^2.28.0"
},
"devDependencies": {
"@babel/core": "^7.28.5",
"@babel/preset-env": "^7.28.5",
"@babel/preset-react": "^7.28.5",
"@babel/preset-typescript": "^7.28.5",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.6.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.4.1",
"assert": "^2.1.0",
"babel-loader": "^10.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.1",
"css-loader": "^7.1.2",
"html-webpack-plugin": "^5.6.5",
"https-browserify": "^1.0.0",
"os-browserify": "^0.3.0",
"process": "^0.11.10",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"style-loader": "^4.0.0",
"typescript": "~5.8.3",
"url": "^0.11.4",
"util": "^0.12.5",
"vitest": "^4.0.8",
"vm-browserify": "^1.1.2",
"webpack": "^5.103.0",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.2"
}
}
14 changes: 14 additions & 0 deletions backend/src/test/react-example/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>React Example</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

Loading