Skip to content

Commit

Permalink
Merge pull request #1 from onflow/feature/stable-cadence
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Jun 18, 2024
2 parents 39af92e + 07f28c9 commit da49a83
Show file tree
Hide file tree
Showing 47 changed files with 2,383 additions and 560 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [main]
branches:
- main
- 'feature/**'
pull_request:
branches: [main]
branches:
- main
- 'feature/**'

env:
GO_VERSION: '1.21'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
test:
Expand All @@ -17,7 +26,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: ${{ env.GO_VERSION }}
- name: Run tests
run: |
make install-tools
Expand All @@ -40,11 +49,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: ${{ env.GO_VERSION }}
- name: generate
run: make generate
- uses: golangci/golangci-lint-action@v3.7.0
- uses: golangci/golangci-lint-action@v5.1.0
with:
version: v1.52.2
args: --timeout=3m
skip-pkg-cache: true
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MIXPANEL_PROJECT_TOKEN := 3fae49de272be1ceb8cf34119f747073

.PHONY: test
test:
GO111MODULE=on go test -coverprofile=$(COVER_PROFILE) $(if $(JSON_OUTPUT),-json,) ./...
GO111MODULE=on go test -v -coverprofile=$(COVER_PROFILE) $(if $(JSON_OUTPUT),-json,) ./...

.PHONY: install-tools
install-tools:
Expand All @@ -27,15 +27,15 @@ install-tools:
GO111MODULE=on go install github.com/axw/gocov/gocov@latest; \
GO111MODULE=on go install github.com/matm/gocov-html/cmd/gocov-html@latest; \
GO111MODULE=on go install github.com/sanderhahn/gozip/cmd/gozip@latest; \
GO111MODULE=on go install github.com/vektra/mockery/v2@v2.38.0;
GO111MODULE=on go install github.com/vektra/mockery/v2@v2.40.3;

.PHONY: generate-schema
generate-schema:
go run ./cmd/flow-schema/flow-schema.go ./schema.json

.PHONY: check-schema
check-schema:
go run ./cmd/flow-schema/flow-schema.go --verify=true ./schema.json
go run ./cmd/flow-schema/flow-schema.go --verify=true ./schema.json

.PHONY: check-tidy
check-tidy:
Expand All @@ -58,4 +58,4 @@ ifeq ($(COVER), true)
gocov-html cover.json > index.html
# coverage.zip will automatically be picked up by teamcity
gozip -c coverage.zip index.html
endif
endif
2 changes: 1 addition & 1 deletion accounts/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/crypto"

"github.com/onflow/flowkit/config"
"github.com/onflow/flowkit/v2/config"
)

// Account is defined by an address and name and contains an Key which can be used for signing.
Expand Down
2 changes: 1 addition & 1 deletion accounts/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
goeth "github.com/onflow/go-ethereum/accounts"
"github.com/tyler-smith/go-bip39"

"github.com/onflow/flowkit/config"
"github.com/onflow/flowkit/v2/config"
)

// PublicKey contains public account key information.
Expand Down
4 changes: 2 additions & 2 deletions accounts/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

"github.com/stretchr/testify/assert"

"github.com/onflow/flowkit/tests"
"github.com/onflow/flowkit/v2/tests"

"github.com/onflow/flowkit/config"
"github.com/onflow/flowkit/v2/config"
)

func Test_KMS_Keys(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion arguments/arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func ParseWithoutType(args []string, code []byte, fileName string) (scriptArgs [
codes := map[common.Location][]byte{}
location := common.StringLocation(fileName)
program, must := cmd.PrepareProgram(code, location, codes)
checker, _ := cmd.PrepareChecker(program, location, codes, nil, must)
checker, _ := cmd.PrepareChecker(program, location, codes, nil, nil, must)

var parameterList []*ast.Parameter

Expand Down
76 changes: 40 additions & 36 deletions arguments/arguments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,84 +45,84 @@ func Test_ParseWithoutType(t *testing.T) {
{
Name: "Address",
Value: cadence.NewAddress([8]byte{0, 0, 0, 0, 0, 0, 0, 1}),
Type: cadence.AddressType{},
Type: cadence.AddressType,
},
{
Name: "Bool",
Value: cadence.NewBool(true),
Type: cadence.BoolType{},
Type: cadence.BoolType,
},
{
Name: "Int",
Value: cadence.NewInt(-42),
Type: cadence.IntType{},
Type: cadence.IntType,
},
{
Name: "Int8",
Value: cadence.NewInt8(-42),
Type: cadence.Int8Type{},
Type: cadence.Int8Type,
},
{
Name: "Int16",
Value: cadence.NewInt16(-42),
Type: cadence.Int16Type{},
Type: cadence.Int16Type,
},
{
Name: "Int32",
Value: cadence.NewInt32(-42),
Type: cadence.Int32Type{},
Type: cadence.Int32Type,
},
{
Name: "Int64",
Value: cadence.NewInt64(-42),
Type: cadence.Int64Type{},
Type: cadence.Int64Type,
},
{
Name: "Int128",
Value: cadence.NewInt128(-42),
Type: cadence.Int128Type{},
Type: cadence.Int128Type,
},
{
Name: "UInt8",
Value: cadence.NewUInt8(42),
Type: cadence.UInt8Type{},
Type: cadence.UInt8Type,
},
{
Name: "UInt16",
Value: cadence.NewUInt16(42),
Type: cadence.UInt16Type{},
Type: cadence.UInt16Type,
},
{
Name: "UInt32",
Value: cadence.NewUInt32(42),
Type: cadence.UInt32Type{},
Type: cadence.UInt32Type,
},
{
Name: "UInt64",
Value: cadence.NewUInt64(42),
Type: cadence.UInt64Type{},
Type: cadence.UInt64Type,
},
{
Name: "UInt128",
Value: cadence.NewUInt128(42),
Type: cadence.UInt128Type{},
Type: cadence.UInt128Type,
},
{
Name: "String",
Value: cadence.String("42"),
Type: cadence.StringType{},
Type: cadence.StringType,
},
{
Name: "String, no quoting",
Literal: `foo`,
Value: cadence.String("foo"),
Type: cadence.StringType{},
Type: cadence.StringType,
},
{
Name: "optional String, nil",
Value: cadence.NewOptional(nil),
Type: &cadence.OptionalType{
Type: cadence.StringType{},
Type: cadence.StringType,
},
},
{
Expand All @@ -131,49 +131,53 @@ func Test_ParseWithoutType(t *testing.T) {
cadence.String("test"),
),
Type: &cadence.OptionalType{
Type: cadence.StringType{},
Type: cadence.StringType,
},
},
{
Name: "doubly optional String, nil",
Value: cadence.NewOptional(
cadence.NewOptional(nil),
),
Type: &cadence.OptionalType{
Type: &cadence.OptionalType{
Type: cadence.StringType,
},
},
},
// TODO: depends on https://github.com/onflow/cadence/pull/2469
//{
// Name: "doubly optional String, nil",
// Value: cadence.NewOptional(
// cadence.NewOptional(nil),
// ),
// Type: &cadence.OptionalType{
// Type: &cadence.OptionalType{
// Type: cadence.StringType{},
// },
// },
//},
{
Name: "variable-sized array",
Value: cadence.NewArray([]cadence.Value{
cadence.String("42"),
}).WithType(&cadence.VariableSizedArrayType{
ElementType: cadence.StringType,
}),
Type: &cadence.VariableSizedArrayType{
ElementType: cadence.StringType{},
ElementType: cadence.StringType,
},
},
{
Name: "constant-sized array",
Value: cadence.NewArray([]cadence.Value{
cadence.String("42"),
}).WithType(&cadence.ConstantSizedArrayType{
ElementType: cadence.StringType,
Size: 1,
}),
Type: &cadence.ConstantSizedArrayType{
ElementType: cadence.StringType{},
ElementType: cadence.StringType,
Size: 1,
},
},
{
Name: "identifier (invalid)",
InvalidLiteral: "foo",
Type: cadence.IntType{},
Type: cadence.IntType,
},
{
Name: "expression (invalid)",
InvalidLiteral: "1 + 1",
Type: cadence.IntType{},
Type: cadence.IntType,
},
}

Expand All @@ -191,7 +195,7 @@ func Test_ParseWithoutType(t *testing.T) {
args, err := ParseWithoutType(
[]string{literal},
[]byte(fmt.Sprintf(
`pub fun main(test: %s) {}`,
`access(all) fun main(test: %s) {}`,
testCase.Type.ID(),
)),
"",
Expand All @@ -217,8 +221,8 @@ func Test_ParseWithoutType(t *testing.T) {
t.Parallel()

template := map[string]string{
"script": `pub fun main(foo: String): Void {}`,
"contract": `pub contract Foo { init(foo: String) {} }`,
"script": `access(all) fun main(foo: String): Void {}`,
"contract": `access(all) contract Foo { init(foo: String) {} }`,
"transaction": `transaction(foo: String) {}`,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/flow-schema/flow-schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"os"
"strings"

configJson "github.com/onflow/flowkit/config/json"
configJson "github.com/onflow/flowkit/v2/config/json"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions config/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ func TestAccounts_Remove(t *testing.T) {
accounts := Accounts{acc1, acc2, acc3}

accounts.Remove("account2")
assert.Equal(t, len(accounts), 2)
assert.Len(t, accounts, 2)

_, err := accounts.ByName("account2")
assert.Error(t, err)

accounts.Remove("account4")
assert.Equal(t, len(accounts), 2)
assert.Len(t, accounts, 2)
}
13 changes: 7 additions & 6 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/onflow/flow-go-sdk/crypto"
"github.com/stretchr/testify/assert"

"github.com/onflow/flowkit/config"
"github.com/onflow/flowkit/v2/config"
)

func generateComplexConfig() config.Config {
Expand Down Expand Up @@ -186,8 +186,8 @@ func Test_GetNetworkByNameComplex(t *testing.T) {

network, err = conf.Networks.ByName("testnet")
assert.NoError(t, err)
assert.Equal(t, network.Host, "access.devnet.nodes.onflow.org:9000")
assert.Equal(t, network.Key, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd")
assert.Equal(t, "access.devnet.nodes.onflow.org:9000", network.Host)
assert.Equal(t, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd", network.Key)
}

func TestConfig_Validate(t *testing.T) {
Expand Down Expand Up @@ -323,13 +323,14 @@ func TestConfig_Validate(t *testing.T) {
func Test_DefaultConfig(t *testing.T) {
cfg := config.Default()
assert.Len(t, cfg.Emulators, 1)
assert.Equal(t, cfg.Emulators[0].Name, "default")
assert.Equal(t, cfg.Emulators[0].ServiceAccount, "emulator-account")
assert.Len(t, cfg.Networks, 4)
assert.Equal(t, "default", cfg.Emulators[0].Name)
assert.Equal(t, "emulator-account", cfg.Emulators[0].ServiceAccount)
assert.Len(t, cfg.Networks, 5)
assert.Equal(t, "emulator", cfg.Networks[0].Name)
assert.Equal(t, "testing", cfg.Networks[1].Name)
assert.Equal(t, "testnet", cfg.Networks[2].Name)
assert.Equal(t, "mainnet", cfg.Networks[3].Name)
assert.Equal(t, "previewnet", cfg.Networks[4].Name)
}

func Test_DefaultPath(t *testing.T) {
Expand Down
Loading

0 comments on commit da49a83

Please sign in to comment.