Skip to content

Commit

Permalink
Update languageserver deps. Update tests to match new cadence syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed Aug 24, 2023
1 parent 6ca1e1f commit cf178ea
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 110 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ Key 0 Public Key c8a2a318b9099cc6c872a0ec3dcd9f59d17837e4ffd6cd8
Hash Algorithm SHA3_256
Code
pub contract Foo {
pub var bar: String
access(all) contract Foo {
access(all) var bar: String
init() {
self.bar = "Hello, World!"
Expand Down
6 changes: 3 additions & 3 deletions flowkit/arguments/arguments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,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 +217,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 flowkit/flowkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ func TestAccountsAddContract_Integration(t *testing.T) {
assert.NoError(t, err)

updated := tests.ContractSimple
updated.Source = []byte(`pub contract Simple { init() {} }`)
updated.Source = []byte(`access(all) contract Simple { init() {} }`)
_, _, err = flowkit.AddContract(
ctx,
srvAcc,
Expand Down
16 changes: 8 additions & 8 deletions flowkit/project/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ var addresses = test.AddressGenerator()

var testContractA = testContract{
location: "ContractA.cdc",
code: []byte(`pub contract ContractA {}`),
code: []byte(`access(all) contract ContractA {}`),
accountAddress: addresses.New(),
}

var testContractB = testContract{
location: "ContractB.cdc",
code: []byte(`pub contract ContractB {}`),
code: []byte(`access(all) contract ContractB {}`),
accountAddress: addresses.New(),
}

Expand All @@ -54,7 +54,7 @@ var testContractC = testContract{
code: []byte(`
import ContractA from "ContractA.cdc"
pub contract ContractC {}
access(all) contract ContractC {}
`),
accountAddress: addresses.New(),
}
Expand All @@ -64,7 +64,7 @@ var testContractD = testContract{
code: []byte(`
import ContractC from "ContractC.cdc"
pub contract ContractD {}
access(all) contract ContractD {}
`),
accountAddress: addresses.New(),
}
Expand All @@ -74,7 +74,7 @@ var testContractE = testContract{
code: []byte(`
import ContractF from "ContractF.cdc"
pub contract ContractE {}
access(all) contract ContractE {}
`),
}

Expand All @@ -83,7 +83,7 @@ var testContractF = testContract{
code: []byte(`
import ContractE from "ContractE.cdc"
pub contract ContractF {}
access(all) contract ContractF {}
`),
accountAddress: addresses.New(),
}
Expand All @@ -94,7 +94,7 @@ var testContractG = testContract{
import ContractA from "ContractA.cdc"
import ContractB from "ContractB.cdc"
pub contract ContractG {}
access(all) contract ContractG {}
`),
accountAddress: addresses.New(),
}
Expand All @@ -104,7 +104,7 @@ var testContractH = testContract{
code: []byte(`
import ContractFoo from "Foo.cdc"
pub contract ContractH {}
access(all) contract ContractH {}
`),
accountAddress: addresses.New(),
}
Expand Down
20 changes: 10 additions & 10 deletions flowkit/project/imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,41 +55,41 @@ func TestResolver(t *testing.T) {
[]byte(`
import Kibble from "./Kibble.cdc"
import FT from "./FT.cdc"
pub fun main() {}
access(all) fun main() {}
`), []byte(`
import Kibble from "../../tests/Kibble.cdc"
import FT from "../../tests/FT.cdc"
pub fun main() {}
access(all) fun main() {}
`), []byte(`
import Kibble from "../../tests/Kibble.cdc"
import NFT from "../../tests/NFT.cdc"
pub fun main() {}
access(all) fun main() {}
`), []byte(`
import Kibble from "./Kibble.cdc"
import Crypto
import Foo from 0x0000000000000001
pub fun main() {}
access(all) fun main() {}
`),
}

resolved := [][]byte{
[]byte(`
import Kibble from 0x0000000000000001
import FT from 0x0000000000000002
pub fun main() {}
access(all) fun main() {}
`), []byte(`
import Kibble from 0x0000000000000001
import FT from 0x0000000000000002
pub fun main() {}
access(all) fun main() {}
`), []byte(`
import Kibble from 0x0000000000000001
import NFT from 0x0000000000000004
pub fun main() {}
access(all) fun main() {}
`), []byte(`
import Kibble from 0x0000000000000001
import Crypto
import Foo from 0x0000000000000001
pub fun main() {}
access(all) fun main() {}
`),
}

Expand Down Expand Up @@ -117,7 +117,7 @@ func TestResolver(t *testing.T) {
import Foo from "./Foo.cdc"
import "Bar"
pub contract Zoo {}
access(all) contract Zoo {}
`)
program, err := NewProgram(code, nil, "./Zoo.cdc")
require.NoError(t, err)
Expand All @@ -129,7 +129,7 @@ func TestResolver(t *testing.T) {
import Foo from 0x0000000000000001
import Bar from 0x0000000000000002
pub contract Zoo {}
access(all) contract Zoo {}
`)

assert.Equal(t, cleanCode(expected), cleanCode(replaced.Code()))
Expand Down
32 changes: 16 additions & 16 deletions flowkit/project/program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ func TestProgram(t *testing.T) {
code []byte
imports []string
}{{
code: []byte(`pub contract Foo {}`),
code: []byte(`access(all) contract Foo {}`),
imports: []string{},
}, {
code: []byte(`pub fun main() {}`),
code: []byte(`access(all) fun main() {}`),
imports: []string{},
}, {
code: []byte(`
import Bar from "./Bar.cdc"
pub contract Foo {}
access(all) contract Foo {}
`),
imports: []string{"./Bar.cdc"},
}, {
code: []byte(`
import Bar from "./Bar.cdc"
import Zoo from "./zoo/Zoo.cdc"
pub contract Foo {}
access(all) contract Foo {}
`),
imports: []string{"./Bar.cdc", "./zoo/Zoo.cdc"},
}, { // new schema import
code: []byte(`
import "Bar"
pub contract Foo {}
access(all) contract Foo {}
`),
imports: []string{"Bar"},
}, {
Expand All @@ -64,7 +64,7 @@ func TestProgram(t *testing.T) {
import Crypto
import Foo from 0x01
pub contract Foo {}
access(all) contract Foo {}
`),
imports: []string{"Bar", "./Zoo.cdc"},
}}
Expand All @@ -82,12 +82,12 @@ func TestProgram(t *testing.T) {
code []byte
name string
}{{
code: []byte(`pub contract Foo {}`),
code: []byte(`access(all) contract Foo {}`),
name: "Foo",
}, {
code: []byte(`
import Bar from "./Bar.cdc"
pub contract Foo {}
access(all) contract Foo {}
`),
name: "Foo",
}}
Expand All @@ -102,15 +102,15 @@ func TestProgram(t *testing.T) {

failed := [][]byte{
[]byte(`
pub contract Foo {}
pub contract Bar {}
access(all) contract Foo {}
access(all) contract Bar {}
`),
[]byte(`
pub contract Foo {}
pub resource interface Test {}
access(all) contract Foo {}
access(all) resource interface Test {}
`),
[]byte(`
pub contract Foo {}
access(all) contract Foo {}
struct Bar {}
`),
}
Expand All @@ -123,7 +123,7 @@ func TestProgram(t *testing.T) {
assert.EqualError(t, err, "the code must declare exactly one contract or contract interface")
}

program, err := NewProgram([]byte(`pub fun main() {}`), nil, "")
program, err := NewProgram([]byte(`access(all) fun main() {}`), nil, "")
require.NoError(t, err)
_, err = program.Name()
assert.EqualError(t, err, "unable to determine contract name")
Expand All @@ -136,7 +136,7 @@ func TestProgram(t *testing.T) {
import FooSpace from "./FooSpace.cdc"
import "BarSpace"
pub contract Foo {}
access(all) contract Foo {}
`)

replaced := []byte(`
Expand All @@ -145,7 +145,7 @@ func TestProgram(t *testing.T) {
import FooSpace from 0x3
import BarSpace from 0x4
pub contract Foo {}
access(all) contract Foo {}
`)

program, err := NewProgram(code, nil, "")
Expand Down
4 changes: 2 additions & 2 deletions flowkit/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func generateAliasesComplexProject() State {
func Test_GetContractsByNameSimple(t *testing.T) {
p := generateSimpleProject()
path := "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc"
af.WriteFile(path, []byte("pub contract{}"), os.ModePerm)
af.WriteFile(path, []byte("access(all) contract{}"), os.ModePerm)

contracts, err := p.DeploymentContractsByNetwork(config.EmulatorNetwork)
require.NoError(t, err)
Expand Down Expand Up @@ -392,7 +392,7 @@ func Test_GetContractsByNameComplex(t *testing.T) {
p := generateComplexProject()

for _, c := range p.conf.Contracts {
_ = af.WriteFile(c.Location, []byte("pub contract{}"), os.ModePerm)
_ = af.WriteFile(c.Location, []byte("access(all) contract{}"), os.ModePerm)
}

contracts, err := p.DeploymentContractsByNetwork(config.EmulatorNetwork)
Expand Down
Loading

0 comments on commit cf178ea

Please sign in to comment.