Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthpun committed Feb 2, 2024
1 parent 588350d commit d3af2e0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 24 deletions.
28 changes: 16 additions & 12 deletions arguments/arguments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,23 @@ func Test_ParseWithoutType(t *testing.T) {
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: "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,
Expand All @@ -159,6 +160,9 @@ func Test_ParseWithoutType(t *testing.T) {
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,
Expand Down
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f // indirect
github.com/onflow/crypto v0.25.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20240125214229-b7a95136dd0d // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20240125214229-b7a95136dd0d // indirect
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240125205519-2e80d9b4bd01 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240125205553-d2b571fb3fad // indirect
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231213135419-ae911cc351a2 // indirect
Expand Down Expand Up @@ -217,3 +217,7 @@ require (
modernc.org/sqlite v1.28.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/onflow/flow-core-contracts/lib/go/contracts => github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20240125214229-b7a95136dd0d

replace github.com/onflow/flow-core-contracts/lib/go/templates => github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20240125214229-b7a95136dd0d
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1839,10 +1839,10 @@ github.com/onflow/cadence v1.0.0-M4 h1:/nt3j7vpYDxuI0ghIgAJrb2R01ijvJYZLAkKt+zbp
github.com/onflow/cadence v1.0.0-M4/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8=
github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f h1:Ep+Mpo2miWMe4pjPGIaEvEzshRep30dvNgxqk+//FrQ=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:ZeLxwaBkzuSInESGjL8/IPZWezF+YOYsYbMrZlhN+q4=
github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20240125214229-b7a95136dd0d h1:Afcfk/9jAQZ1v5PLGdP68FG/0yPPM60fn9Eq8ChBGS0=
github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20240125214229-b7a95136dd0d/go.mod h1:Ts/HN+N0RaYJ6oPCqR1JPaMVFiVaMdKTSUH4OdSjjs0=
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20240125214229-b7a95136dd0d h1:IQJpP3VLLjT4R8ItBpr+Mmp0IOnC/8iBcM0/67JNB9c=
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20240125214229-b7a95136dd0d/go.mod h1:MZ2j5YVTQiSE0B99zuaYhxvGG5GcvimWpQK1Fw/1QBg=
github.com/onflow/flow-emulator v1.0.0-M1 h1:0hBEmvm73F+5HhN5ugkOP3UyN+Ea9yGWflEmoeGzgdw=
github.com/onflow/flow-emulator v1.0.0-M1/go.mod h1:JFJCeQVyhCQVD2Tq4QhctIXK6j5U6aU15yoEwMJt5AQ=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240125205519-2e80d9b4bd01 h1:8iKk5RuFvhe7NQyAO3c+xiVvv38RB/yopHdWxp4AbL8=
Expand Down
21 changes: 16 additions & 5 deletions tests/testnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ func initTestnet(t *testing.T) (gateway.Gateway, *flowkit.State, flowkit.Service
// The Vault resource that holds the tokens that are being transferred
let sentVault: @FungibleToken.Vault
prepare(signer: AuthAccount) {
prepare(signer: auth(BorrowValue) &Account) {
// Get a reference to the signer's stored vault
let vaultRef = signer.borrow<&FlowToken.Vault>(from: /storage/flowTokenVault)
let vaultRef = signer.storage.borrow<auth(FungibleToken.Withdrawable) &FlowToken.Vault>(from: /storage/flowTokenVault)
?? panic("Could not borrow reference to the owner's Vault!")
// Withdraw tokens from the signer's stored vault
Expand All @@ -109,8 +109,7 @@ func initTestnet(t *testing.T) (gateway.Gateway, *flowkit.State, flowkit.Service
// Get a reference to the recipient's Receiver
let receiverRef = getAccount(to)
.getCapability(/public/flowTokenReceiver)
.borrow<&{FungibleToken.Receiver}>()
.capabilities..borrow<&{FungibleToken.Receiver}>(/public/flowTokenReceiver)
?? panic("Could not borrow receiver reference to the recipient's Vault")
// Deposit the withdrawn tokens in the recipient's receiver
Expand All @@ -136,6 +135,12 @@ func initTestnet(t *testing.T) (gateway.Gateway, *flowkit.State, flowkit.Service
var testnet = config.TestnetNetwork.Name

func Test_Foo(t *testing.T) {

// This test relies on a contract deployed on testnet,
// written in old cadence version, which no longer valid.
// TODO: enable once the testnet contract is updated.
t.SkipNow()

_, st, _, rw, _ := initTestnet(t)

rw.WriteFile("test", []byte("foo"), 0644)
Expand All @@ -149,6 +154,12 @@ func Test_Foo(t *testing.T) {
}

func Test_Testnet_ProjectDeploy(t *testing.T) {

// This test relies on a contract deployed on testnet,
// written in old cadence version, which no longer valid.
// TODO: enable once the testnet contract is updated.
t.SkipNow()

_, state, flow, rw, _ := initTestnet(t)

state.Contracts().AddOrUpdate(config.Contract{
Expand Down Expand Up @@ -202,4 +213,4 @@ func Test_Testnet_ProjectDeploy(t *testing.T) {
assert.Equal(t, ContractB.Name, contracts[1].Name)
assert.Equal(t, ContractB.Source, updated)
assert.Equal(t, ContractC.Name, contracts[2].Name)
}
}
2 changes: 1 addition & 1 deletion transactions/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestNew(t *testing.T) {

script := []byte(`
transaction (arg: Int) {
prepare(auth: AuthAccount) {}
prepare(signer: &Account) {}
execute {}
}
`)
Expand Down

0 comments on commit d3af2e0

Please sign in to comment.