Skip to content

Commit

Permalink
test: add contract builder test interface, no impl (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
eng-cc authored Jul 26, 2023
1 parent a4912d7 commit f06f07d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ name: "CodeQL"
on:
push:
branches: ["master"]
paths-ignore:
- "skboa"
- "node_modules"
pull_request:
# The branches below must be a subset of the branches above
branches: ["master"]
paths-ignore:
- "skboa"
- "node_modules"
schedule:
- cron: "39 13 * * 0"

Expand All @@ -32,7 +38,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: ["javascript", "TypeScript"]
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

Expand Down
9 changes: 9 additions & 0 deletions packages/webui/src/ci/contract/builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { buildCodeString } from '@trustack/contract_builder';

export const buildCode = async (): Promise<string> => {
const codeString = await import('./test.contract.ts?raw');
// console.log(codeString);
const { code } = await buildCodeString(codeString.default);

return code;
};
16 changes: 16 additions & 0 deletions packages/webui/src/ci/contract/test.contract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BaseContract } from 'skchain';

export class TestContract extends BaseContract {
constructor() {
super();
this.data = {
value: 10000000000000n,
};
}

data: { [key: string]: bigint } = {};

public getValue = (): bigint => {
return this.data.value;
};
}
10 changes: 10 additions & 0 deletions packages/webui/src/ci/contract/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { evalFunction } from 'skchain';
import { buildCode } from './builder';

export const runBuildContractTest = async (): Promise<boolean> => {
const code = await buildCode();
// console.log(code);
// evalFunction(``);
// TODO: eval code to test
return true;
};
18 changes: 18 additions & 0 deletions packages/webui/src/ci/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Button } from 'antd';
import { useState } from 'react';
import { runBuildContractTest } from './contract/test';
import { runContractTest, runSkvmTest, runTest } from './run';

export default function CiPage() {
const [passed, setPass] = useState(false);
const [skvmPassed, setSkvmPass] = useState(false);
const [contractPassed, setContractPass] = useState(false);
const [contractBuildPassed, setContractBuildPass] = useState(false);
return (
<div className="ci-box">
<div>
Expand Down Expand Up @@ -49,6 +51,22 @@ export default function CiPage() {
</Button>
<span data-testid="contract_passed">{contractPassed.toString()}</span>
</div>

<div style={{ padding: 50 }}>
<Button
data-testid="test_contract_build"
type="default"
onClick={async () => {
const res = await runBuildContractTest();
setContractBuildPass(res);
}}
>
test_build_contract
</Button>
<span data-testid="contract_build_passed">
{contractBuildPassed.toString()}
</span>
</div>
</div>
);
}

0 comments on commit f06f07d

Please sign in to comment.