Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Implement behaviour testing for cairo 1.0 #1047

Merged
merged 8 commits into from
May 17, 2023
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
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ FROM node:19.0.0

RUN apt-get update && apt-get install -y libz3-dev libgmp3-dev python3-pip python-is-python3

RUN echo 'deb http://deb.debian.org/debian sid main' >> /etc/apt/sources.list && \
apt-get update && \
apt-get -y -t sid install libc6

WORKDIR /usr/src/warp-stable
COPY . .

Expand All @@ -10,5 +14,6 @@ RUN pip install -r requirements.txt
RUN yarn warplib
RUN ln -s /usr/src/warp-stable/bin/warp /usr/local/bin/warp

USER node
WORKDIR /dapp
ENTRYPOINT [ "warp" ]
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ services:
entrypoint: tail -F anything

devnet:
image: shardlabs/starknet-devnet:0.3.3-seed0
image: shardlabs/starknet-devnet:0.5.1-seed0
ports:
- '5050:5050'
11 changes: 3 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
wheel
flask[async]
flask-cors >= 3.0.10
# Required by the testnet
cairo-lang==0.10.3
# Requrired by the cli test
starknet-devnet==0.4.4
# Fix until cairo-lang supports web3 v6 or adds a matching pattern for v5
web3==5.*
# Fix until cairo-lang 0.11 is released
typeguard==2.*
# Required by runtime tests
cairo-lang==0.11.0.2
starknet-devnet==0.5.1
6 changes: 5 additions & 1 deletion src/passes/sourceUnitSplitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ function mangleFreeFilePath(path: string): string {
return join(path, FREE_FILE_NAME);
}

function mangleContractFilePath(path: string, contractName: string, extension: string): string {
export function mangleContractFilePath(
path: string,
contractName: string,
extension: string,
): string {
return join(path, 'src', contractName + extension);
}

Expand Down
23 changes: 21 additions & 2 deletions tests/behaviour/behaviour.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
rodrigo-pino marked this conversation as resolved.
Show resolved Hide resolved
import * as fs from 'fs';

import {
Expand All @@ -9,7 +10,7 @@ import {
compileCluster,
removeOutputDir,
} from '../util';
import { deploy, ensureTestnetContactable, invoke } from '../testnetInterface';
import { deploy, ensureTestnetContactable, invoke, starknetCliCall } from '../testnetInterface';

import { describe } from 'mocha';
import { expect } from 'chai';
Expand All @@ -18,6 +19,10 @@ import { AsyncTest, Expect, OUTPUT_DIR } from './expectations/types';
import { DeployResponse } from '../testnetInterface';
import { getDependencyGraph } from '../../src/utils/postCairoWrite';
import { EventItem } from '../../src/utils/event';
import { BASE_PATH, compileCairo1 } from '../../src/starknetCli';
import path from 'path';
import { execSync } from 'child_process';
import { DEVNET_URL } from '../config';

const PRINT_STEPS = false;
const PARALLEL_COUNT = 8;
Expand All @@ -28,6 +33,19 @@ interface AsyncTestCluster {
dependencies: Map<string, string[]>;
}

fs.writeFileSync(
path.join(BASE_PATH, '.starknet_accounts_devnet', 'starknet_open_zeppelin_accounts.json'),
'{}',
);
const address = execSync(`${starknetCliCall('new_account', '')} | awk 'NR==1 {printf $3}'`);
console.log(`New address: ${address}`);
const addFunds = `curl ${DEVNET_URL}/mint -H "Content-Type: application/json" -d '{"address": "${address}", "amount": 1000000000000000000}'`;
console.log(addFunds);
console.log(execSync(addFunds).toString());
console.log('Deploying account:');
const account_deployed = execSync(starknetCliCall('deploy_account', ''));
console.log(account_deployed.toString());

// Transpiling the solidity files using the `bin/warp transpile` CLI command.
describe('Transpile solidity', function () {
this.timeout(TIME_LIMIT);
Expand Down Expand Up @@ -88,7 +106,8 @@ describe('Transpiled contracts are valid cairo', function () {
return Promise.resolve(null);
}
// This is will compile the test and declare all of the dependencies that it needs.
return compileCluster(test);
let compiled = compileCairo1(test.asyncTest.projectRoot);
return Promise.resolve({ stderr: compiled.success ? '' : 'Compilation failed' });
},
);
});
Expand Down
Loading