-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add contract bundle test (#121)
- Loading branch information
Showing
15 changed files
with
53 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: 'Dev Log 2023-08' | ||
description: '' | ||
--- | ||
|
||
### 8-01~8-21 | ||
|
||
- [x] 因为 swcpack 无法在浏览器运行,所以选择先不做浏览器内打包合约的功能,仅在 NodeJs 环境下做合约编译打包 | ||
- [x] swcpack 在 NodeJs 环境下打包仍然有问题,从 swc 主仓库看起来是相关功能还没做完,所以选择 rollup 来做合约打包 | ||
- [x] rollup 打包合约成功,但是打包出来的合约文件中的代码在 vm 中运行报错(Date.now() 未定义),排查了好久复现是 vm 入口文件未引入 chrono, 并修复了这个问题 | ||
- [x] 添加了合约打包的测试用例,e2e 测试用例中包含了合约打包后的代码在 vm 中运行的测试 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
*.contract.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { evalCode } from '@trustack/contract'; | ||
import { bytes } from 'multiformats'; | ||
|
||
export const runBuildContractTest = async (): Promise<boolean> => { | ||
export const runContractBundleTest = async (): Promise<boolean> => { | ||
const codeByte = (await import('./test.contract.js')) as unknown as { | ||
default: Uint8Array; | ||
}; | ||
const codeString = bytes.toString(codeByte.default); | ||
|
||
console.log(codeString); | ||
// TODO: eval code to test | ||
return true; | ||
const res = await evalCode( | ||
`${codeString};const func = new __contract_class_name__(); func.getValue();`, | ||
); | ||
return res.funcResult === '10000000000000n'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const add = (a: number, b: number): number => a + b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters