mirror of https://github.com/status-im/nimplay.git
Add Basic print example.
This commit is contained in:
parent
0a3990465c
commit
1465125f57
8
Makefile
8
Makefile
|
@ -10,7 +10,7 @@ DOCKER_NLVM_C=$(DOCKER_NLVM) $(PATH_PARAMS) $(NLVM_WAMS32_FLAGS) c
|
|||
# Use nim + clang
|
||||
DOCKER_NIM_CLANG=docker run -e HOME='/tmp/' --user $(user_id):$(user_id) -w /code/ -v $(pwd):/code/ --entrypoint="/usr/bin/nim" jacqueswww/nimclang --verbosity:2
|
||||
DOCKER_NIM_CLANG_PASS_FLAGS = --passC:"--target=wasm32-unknown-unknown-wasm" \
|
||||
--passL:"--target=wasm32-unknown-unknown-wasm" --passC:"-I./include" --clang.options.linker:"-nostdlib -Wl,--no-entry,--allow-undefined,--strip-all,--export-dynamic"
|
||||
--passL:"--target=wasm32-unknown-unknown-wasm" --passC:"-I./include" --clang.options.linker:"-nostdlib -Wl,--no-entry,--allow-undefined,--strip-all,--export-dynamic,--import-memory,--max-memory=131072"
|
||||
DOCKER_NIM_CLANG_FLAGS=$(DOCKER_NIM_CLANG_PASS_FLAGS) --os:standalone --cpu:i386 --cc:clang --gc:none --nomain -d:release
|
||||
DOCKER_NIM_CLANG_C=$(DOCKER_NIM_CLANG) --cc:clang $(PATH_PARAMS) c
|
||||
DOCKER_NIM_CLANG_WASM32_C=$(DOCKER_NIM_CLANG) $(DOCKER_NIM_CLANG_FLAGS) $(PATH_PARAMS) c
|
||||
|
@ -86,11 +86,17 @@ test-ee: ee-examples
|
|||
cd tests/ee/; \
|
||||
./test.sh
|
||||
|
||||
|
||||
|
||||
SUBSTRATE_POSTPROCESS=tools/substrate_postprocess.sh
|
||||
|
||||
.PHONY: substrate-examples
|
||||
substrate-examples:
|
||||
$(WASM32_NIMC) --out:examples/substrate/hello_world.wasm examples/substrate/hello_world.nim
|
||||
$(SUBSTRATE_POSTPROCESS) examples/substrate/hello_world.wasm
|
||||
|
||||
.PHONY: test-substrate
|
||||
test-substrate: substrate-examples
|
||||
cd tests/substrate; \
|
||||
SUBSTRATE_PATH="${HOME}/.cargo/bin/substrate" ./test.sh
|
||||
|
||||
|
|
|
@ -4,3 +4,11 @@ proc rawoutput(s: string) =
|
|||
revert(cstring(s), s.len.int32)
|
||||
proc panic(s: string) = rawoutput(s)
|
||||
{.pop.}
|
||||
|
||||
|
||||
# Try LLVm builtin unreachable:
|
||||
# void myabort(void) __attribute__((noreturn));
|
||||
# void myabort(void) {
|
||||
# asm("int3");
|
||||
# __builtin_unreachable();
|
||||
# }
|
||||
|
|
|
@ -12,7 +12,7 @@ fi
|
|||
|
||||
# Purge dev chain and then spin up the substrate node in background
|
||||
$SUBSTRATE_PATH purge-chain --dev -y
|
||||
$SUBSTRATE_PATH --dev &
|
||||
$SUBSTRATE_PATH --dev -l debug &
|
||||
SUBSTRATE_PID=$!
|
||||
|
||||
# # Execute tests
|
||||
|
|
|
@ -79,18 +79,10 @@ describe("Nimplay Hello World", () => {
|
|||
STORAGE_KEY
|
||||
);
|
||||
expect(initialValue).toBeDefined();
|
||||
expect(initialValue.toString()).toEqual("0x00");
|
||||
expect(initialValue.toString()).toEqual("");
|
||||
|
||||
await callContract(api, testAccount, address, "0x00");
|
||||
|
||||
const newValue = await getContractStorage(api, address, STORAGE_KEY);
|
||||
expect(newValue.toString()).toEqual("0x01");
|
||||
|
||||
await callContract(api, testAccount, address, "0x00");
|
||||
|
||||
const flipBack = await getContractStorage(api, address, STORAGE_KEY);
|
||||
expect(flipBack.toString()).toEqual("0x00");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ export async function putCode(
|
|||
.toString("hex");
|
||||
const tx = api.tx.contracts.putCode(gasRequired, `0x${wasmCode}`);
|
||||
const result: any = await sendAndReturnFinalized(signer, tx);
|
||||
console.log('result', result)
|
||||
const record = result.findRecord("contracts", "CodeStored");
|
||||
|
||||
if (!record) {
|
||||
|
|
|
@ -10,9 +10,7 @@ set -ex
|
|||
wasm2wat="docker run --entrypoint=wasm2wat -w /code/ -v $(pwd):/code/ jacqueswww/nimclang "
|
||||
wat2wasm="docker run --entrypoint=wat2wasm -w /code/ -v $(pwd):/code/ jacqueswww/nimclang "
|
||||
|
||||
# Replace "env" with "ethereum"
|
||||
$wasm2wat "$WASM_FILE" |
|
||||
sed 's/(import "env" /(import "ethereum" /g' |
|
||||
sed '/(export.*memory\|main.*/! s/(export.*//g' > ./wasm.tmp
|
||||
|
||||
$wat2wasm -o "$WASM_FILE" ./wasm.tmp
|
||||
|
|
Loading…
Reference in New Issue