aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml22
-rw-r--r--.gitignore47
-rw-r--r--plugin/evm/service.go25
-rwxr-xr-xscripts/build.sh (renamed from scripts/build_coreth.sh)0
-rwxr-xr-xscripts/build_test.sh7
5 files changed, 94 insertions, 7 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..31ae101
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,22 @@
+name: CI
+on: [pull_request, push]
+
+jobs:
+ test:
+ name: Golang v${{ matrix.go }} (${{ matrix.os }})
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ go: ['1.15']
+ os: [macos-10.15, macos-11.0, ubuntu-18.04, ubuntu-20.04, windows-latest]
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-go@v1
+ with:
+ go-version: ${{ matrix.go }}
+ - run: go mod download
+ shell: bash
+ - run: ./scripts/build.sh evm
+ shell: bash
+ - run: ./scripts/build_test.sh
+ shell: bash
diff --git a/.gitignore b/.gitignore
index 7b81853..80f9dd1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,48 @@
./main
+
+*.log
+*~
+.DS_Store
+
+awscpu
+
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+*.profile
+
+# Test binary, build with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# ignore GoLand metafiles directory
+.idea/
+
+*logs/
+
+.vscode*
+
+*.pb*
+
+db*
+
+*cpu[0-9]*
+*mem[0-9]*
+*lock[0-9]*
+*.profile
+*.swp
+*.aux
+*.fdb*
+*.fls
+*.gz
+*.pdf
+
+.coverage
+
+bin/
+build/
diff --git a/plugin/evm/service.go b/plugin/evm/service.go
index 65ef3a2..fc7ed69 100644
--- a/plugin/evm/service.go
+++ b/plugin/evm/service.go
@@ -91,6 +91,17 @@ func (api *SnowmanAPI) IssueBlock(ctx context.Context) error {
return api.vm.tryBlockGen()
}
+// parseAssetID parses an assetID string into an ID
+func (service *AvaxAPI) parseAssetID(assetID string) (ids.ID, error) {
+ if assetID == "" {
+ return ids.ID{}, fmt.Errorf("assetID is required")
+ } else if assetID == "AVAX" {
+ return service.vm.ctx.AVAXAssetID, nil
+ } else {
+ return ids.FromString(assetID)
+ }
+}
+
// ClientVersion returns the version of the vm running
func (service *AvaxAPI) ClientVersion() string { return version }
@@ -232,8 +243,6 @@ func (service *AvaxAPI) Import(_ *http.Request, args *ImportArgs, response *api.
type ExportAVAXArgs struct {
api.UserPass
- // AssetID of the tokens
- AssetID ids.ID `json:"assetID"`
// Amount of asset to send
Amount json.Uint64 `json:"amount"`
@@ -247,7 +256,7 @@ type ExportAVAXArgs struct {
func (service *AvaxAPI) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JSONTxID) error {
return service.Export(nil, &ExportArgs{
ExportAVAXArgs: *args,
- AssetID: service.vm.ctx.AVAXAssetID,
+ AssetID: service.vm.ctx.AVAXAssetID.String(),
}, response)
}
@@ -255,15 +264,17 @@ func (service *AvaxAPI) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, respon
type ExportArgs struct {
ExportAVAXArgs
// AssetID of the tokens
- AssetID ids.ID `json:"assetID"`
+ AssetID string `json:"assetID"`
}
// Export exports an asset from the C-Chain to the X-Chain
// It must be imported on the X-Chain to complete the transfer
func (service *AvaxAPI) Export(_ *http.Request, args *ExportArgs, response *api.JSONTxID) error {
log.Info("EVM: Export called")
- if args.AssetID == ids.Empty {
- return fmt.Errorf("assetID is required")
+
+ assetID, err := service.parseAssetID(args.AssetID)
+ if err != nil {
+ return err
}
if args.Amount == 0 {
@@ -290,7 +301,7 @@ func (service *AvaxAPI) Export(_ *http.Request, args *ExportArgs, response *api.
// Create the transaction
tx, err := service.vm.newExportTx(
- args.AssetID, // AssetID
+ assetID, // AssetID
uint64(args.Amount), // Amount
chainID, // ID of the chain to send the funds to
to, // Address
diff --git a/scripts/build_coreth.sh b/scripts/build.sh
index 41fab1b..41fab1b 100755
--- a/scripts/build_coreth.sh
+++ b/scripts/build.sh
diff --git a/scripts/build_test.sh b/scripts/build_test.sh
new file mode 100755
index 0000000..46a619f
--- /dev/null
+++ b/scripts/build_test.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+go test -race -timeout="90s" -coverprofile="coverage.out" -covermode="atomic" ./plugin/...