diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..cf9b3b4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Test + +on: + push: + branches: [ "main" ] + pull_request: + +jobs: + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: + recursive + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.22' + + - name: Build contracts + run: sudo make build-contracts + + - name: Test + run: go test -v ./... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01aee6c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +contracts_wasm diff --git a/Makefile b/Makefile index ea74acc..6f2a896 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,23 @@ ### Build contracts ### ########################### -build-contracts: +#!/bin/bash +UNAMEP := $(shell uname -p) +build-contracts: + echo $(UNAMEP) + mkdir -p contracts_wasm cd contracts; make build; cd .. - for file in ./contracts/artifacts/*.wasm; do \ - echo "$$file"; \ - mv "$$file" ./contracts_wasm/$$(basename "$$file" -aarch64.wasm).wasm; \ - done - cp ./contracts/artifacts/** ./contracts_wasm/ + for file in ./contracts/artifacts/*; do \ + if [ $(UNAMEP) = arm ]; then \ + echo "$$file"; \ + BASENAME=$$(basename $$file); \ + NEWNAME=$$(echo $$BASENAME | sed 's/-aarch64//'); \ + mv $$file ./contracts_wasm/$$NEWNAME; \ + else \ + echo "$$file"; \ + mv "$$file" ./contracts_wasm; \ + fi \ + done .PHONY: build-contracts diff --git a/avida_ibc_test.go b/avida_ibc_test.go index cf34cb9..9ff7541 100644 --- a/avida_ibc_test.go +++ b/avida_ibc_test.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "runtime" "testing" sdjwttypes "github.com/nymlab/cheqd-interchaintest/types" @@ -22,12 +23,23 @@ import ( func TestCheqdV2AvidaIbc(t *testing.T) { t.Parallel() + var cheqd_version string + var repository string + + if runtime.GOARCH == "arm64" { + cheqd_version = "v2.0.1-arm64" + repository = "ghcr.io/nymlab/cheqd-node" + } else { + cheqd_version = "sha-fdf3b2cb9bef2ee518f46e299eee97b4c4082ff2" + repository = "ghcr.io/cheqd/cheqd-node" + } + cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ { Name: "cheqd", ChainName: "cheqd", - Version: "v2.0.1-arm64", - ChainConfig: GetCheqdConfig(), + Version: cheqd_version, + ChainConfig: GetCheqdConfig(cheqd_version, repository), NoHostMount: &[]bool{false}[0], // specify no mount }, { diff --git a/cheqd.go b/cheqd.go index 64f0e7f..2fafddf 100644 --- a/cheqd.go +++ b/cheqd.go @@ -42,6 +42,7 @@ func CreateAndUploadDid( ) []byte { err := MustUploadPayload(ctx, "artifacts", didPayload, chain) + require.NoError(t, err, "upload file err") err = MustUploadPayload(ctx, "artifacts", resourcePayload, chain) require.NoError(t, err, "upload file err") diff --git a/cheqd_test.go b/cheqd_test.go index 03ec7ad..13ef4ef 100644 --- a/cheqd_test.go +++ b/cheqd_test.go @@ -2,6 +2,7 @@ package cheqd_interchaintest import ( "context" + "runtime" "testing" interchaintest "github.com/strangelove-ventures/interchaintest/v7" @@ -22,11 +23,24 @@ func TestCheqdV2UploadResource(t *testing.T) { // create a single chain instance with x validators validatorsCount, fullnodeCount := 1, 1 + var cheqd_version string + var repository string + + if runtime.GOARCH == "arm64" { + cheqd_version = "v2.0.1-arm64" + repository = "ghcr.io/nymlab/cheqd-node" + } else { + cheqd_version = "sha-fdf3b2cb9bef2ee518f46e299eee97b4c4082ff2" + repository = "ghcr.io/cheqd/cheqd-node" + } + ic, cheqd, _, _ := CreateCheqdChain( t, ctx, validatorsCount, fullnodeCount, + cheqd_version, + repository, ) require.NotNil(t, ic) require.NotNil(t, cheqd) diff --git a/contracts b/contracts index 017cca9..1a985c7 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 017cca96cd192bf0c5043e6b5cf34e07667586bf +Subproject commit 1a985c7e57e84b85ed721bc83e315c9f85e43eb1 diff --git a/contracts_wasm/avida_sdjwt_verifier.wasm b/contracts_wasm/avida_sdjwt_verifier.wasm deleted file mode 100644 index f317703..0000000 Binary files a/contracts_wasm/avida_sdjwt_verifier.wasm and /dev/null differ diff --git a/contracts_wasm/checksums.txt b/contracts_wasm/checksums.txt deleted file mode 100644 index a70ad57..0000000 --- a/contracts_wasm/checksums.txt +++ /dev/null @@ -1 +0,0 @@ -2b2b15f3d4cea85a50b8bda772ad6be2328924b667e14eb0165aa1f5fd41b195 avida_sdjwt_verifier-aarch64.wasm diff --git a/setup.go b/setup.go index 8074c93..35d5792 100644 --- a/setup.go +++ b/setup.go @@ -68,16 +68,16 @@ func GetJunoEncoding() *testutil.TestEncodingConfig { return &cfg } -func GetCheqdConfig() ibc.ChainConfig { +func GetCheqdConfig(cheqd_version string, repository string) ibc.ChainConfig { return ibc.ChainConfig{ Type: "cosmos", Name: "cheqd", ChainID: "cheqd-mainnet-1", Images: []ibc.DockerImage{ { - Repository: "ghcr.io/nymlab/cheqd-node", // FOR LOCAL IMAGE USE: Docker Image Name + Repository: repository, // FOR LOCAL IMAGE USE: Docker Image Name //Repository: "ghcr.io/strangelove-ventures/heighliner/cheqd", // FOR LOCAL IMAGE USE: Docker Image Name - Version: "v2.0.1-arm64", // FOR LOCAL IMAGE USE: Docker Image Tag + Version: cheqd_version, // FOR LOCAL IMAGE USE: Docker Image Tag UidGid: "1000:1000", }, }, @@ -123,14 +123,16 @@ func CreateCheqdChain( t *testing.T, ctx context.Context, numVals, numFull int, + cheqd_version string, + repository string, ) (*interchaintest.Interchain, *cosmos.CosmosChain, *client.Client, string) { cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ { Name: "cheqd", ChainName: "cheqd", - Version: "v2.0.1-arm64", - ChainConfig: GetCheqdConfig(), + Version: cheqd_version, + ChainConfig: GetCheqdConfig(cheqd_version, repository), NoHostMount: &[]bool{false}[0], // specify no mount NumValidators: &numVals, NumFullNodes: &numFull,