forked from CosmWasm/wasmd
-
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.
Merge pull request CosmWasm#42 from oraichain/cherry-pick-interchaintest
Feat: Set up interchaintest (CosmWasm#35)
- Loading branch information
Showing
6 changed files
with
2,344 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG GO_VERSION="1.22.6" | ||
# -------------------------------------------------------- | ||
# Builder | ||
# -------------------------------------------------------- | ||
|
||
FROM golang:${GO_VERSION}-alpine as builder | ||
|
||
ARG GIT_VERSION | ||
ARG GIT_COMMIT | ||
|
||
RUN apk add --no-cache \ | ||
ca-certificates \ | ||
build-base \ | ||
linux-headers | ||
|
||
# Download go dependencies | ||
WORKDIR /orai | ||
COPY go.mod go.sum ./ | ||
|
||
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | ||
|
||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/root/go/pkg/mod \ | ||
go mod download | ||
|
||
RUN set -eux; \ | ||
export ARCH=$(uname -m); \ | ||
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $2}'); \ | ||
if [ ! -z "${WASM_VERSION}" ]; then \ | ||
wget -O /usr/local/lib/libwasmvm_muslc.${ARCH}.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a; \ | ||
fi; \ | ||
go mod download; | ||
|
||
# Copy the remaining files | ||
COPY . . | ||
|
||
# Build oraid binary | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/root/go/pkg/mod \ | ||
GOWORK=off go build \ | ||
-mod=readonly \ | ||
-tags "netgo,ledger,muslc" \ | ||
-ldflags \ | ||
"-X github.com/cosmos/cosmos-sdk/version.Name="orai" \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName="oraid" \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=${GIT_VERSION} \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=${GIT_COMMIT} \ | ||
-X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc \ | ||
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \ | ||
-trimpath \ | ||
-o /orai/bin/oraid \ | ||
/orai/cmd/wasmd | ||
|
||
# -------------------------------------------------------- | ||
# Runner | ||
# -------------------------------------------------------- | ||
|
||
FROM alpine:3.16 | ||
|
||
COPY --from=builder /orai/bin/oraid /usr/bin/oraid | ||
|
||
ENV PATH=/usr/bin:$PATH | ||
|
||
ENV HOME=/.oraid | ||
WORKDIR $HOME | ||
|
||
# rest server | ||
EXPOSE 1317 | ||
# tendermint p2p | ||
EXPOSE 26656 | ||
# tendermint rpc | ||
EXPOSE 26657 | ||
# grpc | ||
EXPOSE 9090 | ||
|
||
ENTRYPOINT ["oraid"] |
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,54 @@ | ||
package interchaintest | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/strangelove-ventures/interchaintest/v8" | ||
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zaptest" | ||
) | ||
|
||
// TestStartOrai is a basic test to assert that spinning up a Orai network with 1 validator works properly. | ||
func TestStartOrai(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip() | ||
} | ||
|
||
t.Parallel() | ||
|
||
numVals := 1 | ||
numFullNodes := 1 | ||
|
||
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ | ||
{ | ||
Name: "orai", | ||
ChainConfig: oraiConfig, | ||
NumValidators: &numVals, | ||
NumFullNodes: &numFullNodes, | ||
}, | ||
}) | ||
|
||
chains, err := cf.Chains(t.Name()) | ||
require.NoError(t, err) | ||
|
||
orai := chains[0].(*cosmos.CosmosChain) | ||
ic := interchaintest.NewInterchain().AddChain(orai) | ||
ctx := context.Background() | ||
client, network := interchaintest.DockerSetup(t) | ||
|
||
require.NoError(t, ic.Build(ctx, nil, interchaintest.InterchainBuildOptions{ | ||
TestName: t.Name(), | ||
Client: client, | ||
NetworkID: network, | ||
SkipPathCreation: true, | ||
})) | ||
t.Cleanup(func() { | ||
_ = ic.Close() | ||
}) | ||
|
||
a, err := orai.AuthQueryModuleAccounts(ctx) | ||
require.NoError(t, err) | ||
t.Log("module accounts", a) | ||
} |
Oops, something went wrong.