Skip to content

Commit

Permalink
adjusts more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Aug 12, 2023
1 parent 6a701e9 commit 6395c0f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
6 changes: 3 additions & 3 deletions runtime/convertValues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ func TestExportReferenceValue(t *testing.T) {
var v:[AnyStruct] = []
acct.storage.save(v, to: /storage/x)
var ref = acct.borrow<auth(Insert) &[AnyStruct]>(from: /storage/x)!
var ref = acct.storage.borrow<auth(Insert) &[AnyStruct]>(from: /storage/x)!
ref.append(ref)
return ref
}
Expand Down Expand Up @@ -1957,8 +1957,8 @@ func TestExportReferenceValue(t *testing.T) {
var v:[AnyStruct] = []
acct.storage.save(v, to: /storage/x)
var ref1 = acct.borrow<auth(Insert) &[AnyStruct]>(from: /storage/x)!
var ref2 = acct.borrow<&[AnyStruct]>(from: /storage/x)!
var ref1 = acct.storage.borrow<auth(Insert) &[AnyStruct]>(from: /storage/x)!
var ref2 = acct.storage.borrow<&[AnyStruct]>(from: /storage/x)!
ref1.append(ref2)
return ref1
Expand Down
65 changes: 33 additions & 32 deletions runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ func TestRuntimeStorage(t *testing.T) {
import "imported"
transaction {
prepare(signer: &Account) {
prepare(signer: auth (Storage) &Account) {
%s
}
}
Expand Down Expand Up @@ -2011,7 +2011,7 @@ func TestRuntimeStorageMultipleTransactionsResourceWithArray(t *testing.T) {
transaction {
prepare(signer: &Account) {
prepare(signer: auth (Storage, Capabilities) &Account) {
signer.storage.save(<-createContainer(), to: /storage/container)
let cap = signer.capabilities.storage.issue<auth(Insert) &Container>(/storage/container)
signer.capabilities.publish(cap, at: /public/container)
Expand Down Expand Up @@ -2131,7 +2131,7 @@ func TestRuntimeStorageMultipleTransactionsResourceFunction(t *testing.T) {
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
signer.storage.save(<-createDeepThought(), to: /storage/deepThought)
}
}
Expand All @@ -2141,7 +2141,7 @@ func TestRuntimeStorageMultipleTransactionsResourceFunction(t *testing.T) {
import "deep-thought"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
let answer = signer.storage.borrow<&DeepThought>(from: /storage/deepThought)?.answer()
log(answer ?? 0)
}
Expand Down Expand Up @@ -2222,7 +2222,7 @@ func TestRuntimeStorageMultipleTransactionsResourceField(t *testing.T) {
import "imported"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
signer.storage.save(<-createNumber(42), to: /storage/number)
}
}
Expand All @@ -2232,7 +2232,7 @@ func TestRuntimeStorageMultipleTransactionsResourceField(t *testing.T) {
import "imported"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
if let number <- signer.storage.load<@SomeNumber>(from: /storage/number) {
log(number.n)
destroy number
Expand Down Expand Up @@ -2317,7 +2317,7 @@ func TestRuntimeCompositeFunctionInvocationFromImportingProgram(t *testing.T) {
import Y, createY from "imported"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
signer.storage.save(<-createY(), to: /storage/y)
}
}
Expand All @@ -2327,7 +2327,7 @@ func TestRuntimeCompositeFunctionInvocationFromImportingProgram(t *testing.T) {
import Y from "imported"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
let y <- signer.storage.load<@Y>(from: /storage/y)
y?.x()
destroy y
Expand Down Expand Up @@ -2398,7 +2398,7 @@ func TestRuntimeResourceContractUseThroughReference(t *testing.T) {
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
signer.storage.save(<-createR(), to: /storage/r)
}
}
Expand All @@ -2409,7 +2409,7 @@ func TestRuntimeResourceContractUseThroughReference(t *testing.T) {
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
let ref = signer.storage.borrow<&R>(from: /storage/r)!
ref.x()
}
Expand Down Expand Up @@ -2486,7 +2486,7 @@ func TestRuntimeResourceContractUseThroughLink(t *testing.T) {
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage, Capabilities) &Account) {
signer.storage.save(<-createR(), to: /storage/r)
let cap = signer.capabilities.storage.issue<&R>(/storage/r)
signer.capabilities.publish(cap, at: /public/r)
Expand Down Expand Up @@ -2584,7 +2584,7 @@ func TestRuntimeResourceContractWithInterface(t *testing.T) {
import R, createR from "imported2"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage, Capabilities) &Account) {
signer.storage.save(<-createR(), to: /storage/r)
let cap = signer.capabilities.storage.issue<&{RI}>(/storage/r)
signer.capabilities.publish(cap, at: /public/r)
Expand Down Expand Up @@ -2985,7 +2985,7 @@ func TestRuntimeStorageChanges(t *testing.T) {
import X, createX from "imported"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
signer.storage.save(<-createX(), to: /storage/x)
let ref = signer.storage.borrow<&X>(from: /storage/x)!
Expand All @@ -2998,7 +2998,7 @@ func TestRuntimeStorageChanges(t *testing.T) {
import X from "imported"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
let ref = signer.storage.borrow<&X>(from: /storage/x)!
log(ref.x)
}
Expand Down Expand Up @@ -3165,7 +3165,7 @@ func TestRuntimeAccountPublishAndAccess(t *testing.T) {
import "imported"
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage, Capabilities) &Account) {
signer.storage.save(<-createR(), to: /storage/r)
let cap = signer.capabilities.storage.issue<&R>(/storage/r)
signer.capabilities.publish(cap, at: /public/r)
Expand Down Expand Up @@ -3246,7 +3246,7 @@ func TestRuntimeTransaction_CreateAccount(t *testing.T) {

script := []byte(`
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
Account(payer: signer)
}
}
Expand Down Expand Up @@ -3433,7 +3433,7 @@ func TestRuntimeInvokeContractFunction(t *testing.T) {
access(all) fun helloAuthAcc(account: &Account) {
log("Hello ".concat(account.address.toString()))
}
access(all) fun helloPublicAcc(account: PublicAccount) {
access(all) fun helloPublicAcc(account: &Account) {
log("Hello access(all) ".concat(account.address.toString()))
}
}
Expand Down Expand Up @@ -3759,8 +3759,8 @@ func TestRuntimeContractNestedResource(t *testing.T) {
transaction {
prepare(acct: &Account) {
log(acct.borrow<&Test.R>(from: /storage/r)?.hello())
prepare(acct: auth(Storage) &Account) {
log(acct.storage.borrow<&Test.R>(from: /storage/r)?.hello())
}
}
`)
Expand Down Expand Up @@ -3835,6 +3835,7 @@ func TestRuntimeStorageLoadedDestructionConcreteType(t *testing.T) {

contract := []byte(`
access(all) contract Test {
access(all) resource R {
// test that the destructor is linked back into the nested resource
// after being loaded from storage
Expand All @@ -3855,7 +3856,7 @@ func TestRuntimeStorageLoadedDestructionConcreteType(t *testing.T) {
transaction {
prepare(acct: &Account) {
prepare(acct: auth(Storage) &Account) {
let r <- acct.storage.load<@Test.R>(from: /storage/r)
destroy r
}
Expand Down Expand Up @@ -3950,7 +3951,7 @@ func TestRuntimeStorageLoadedDestructionAnyResource(t *testing.T) {
transaction {
prepare(acct: &Account) {
prepare(acct: auth(Storage) &Account) {
let r <- acct.storage.load<@AnyResource>(from: /storage/r)
destroy r
}
Expand Down Expand Up @@ -4046,7 +4047,7 @@ func TestRuntimeStorageLoadedDestructionAfterRemoval(t *testing.T) {
transaction {
prepare(acct: &Account) {
prepare(acct: auth(Storage) &Account) {
let r <- acct.storage.load<@AnyResource>(from: /storage/r)
destroy r
}
Expand Down Expand Up @@ -4253,7 +4254,7 @@ func TestRuntimeFungibleTokenUpdateAccountCode(t *testing.T) {
transaction {
prepare(acct: &Account) {
prepare(acct: auth(Capabilities) &Account) {
let receiverCap = acct.capabilities.storage
.issue<&{FungibleToken.Receiver}>(/storage/vault)
Expand All @@ -4271,7 +4272,7 @@ func TestRuntimeFungibleTokenUpdateAccountCode(t *testing.T) {
transaction {
prepare(acct: &Account) {
prepare(acct: auth(Storage, Capabilities) &Account) {
let vault <- FungibleToken.createEmptyVault()
acct.storage.save(<-vault, to: /storage/vault)
Expand Down Expand Up @@ -4368,7 +4369,7 @@ func TestRuntimeFungibleTokenCreateAccount(t *testing.T) {
deploy := []byte(fmt.Sprintf(
`
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
let acct = Account(payer: signer)
acct.contracts.add(name: "FungibleToken", code: "%s".decodeHex())
}
Expand Down Expand Up @@ -4490,7 +4491,7 @@ func TestRuntimeInvokeStoredInterfaceFunction(t *testing.T) {
return []byte(fmt.Sprintf(
`
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
let acct = Account(payer: signer)
acct.contracts.add(name: "%s", code: "%s".decodeHex())
}
Expand Down Expand Up @@ -5158,7 +5159,7 @@ func TestRuntimeResourceOwnerFieldUseArray(t *testing.T) {
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage, Capabilities) &Account) {
let rs <- [
<-Test.createR(),
Expand Down Expand Up @@ -7591,7 +7592,7 @@ func TestRuntimeComputationMetring(t *testing.T) {
fmt.Sprintf(
`
transaction {
prepare(acc: &Account) {
prepare(acc: auth(Storage) &Account) {
%s
}
}
Expand Down Expand Up @@ -7894,7 +7895,7 @@ func TestRuntimeTypeMismatchErrorMessage(t *testing.T) {
transaction {
prepare(acct: &Account) {
prepare(acct: auth(Storage) &Account) {
acct.storage.save(Foo.Bar(), to: /storage/bar)
}
}
Expand Down Expand Up @@ -8051,15 +8052,15 @@ func TestRuntimeAccountTypeEquality(t *testing.T) {

script := []byte(`
access(all) fun main(address: Address): AnyStruct {
let acct = getAuthAccount(address)
let acct = getAuthAccount<auth(Capabilities) &Account>(address)
let path = /public/tmp
let cap = acct.capabilities.account.issue<&Account>()
acct.capabilities.publish(cap, at: path)
let capType = acct.capabilities.borrow<&Account>(path)!.getType()
return Type<AuthAccount>() == capType
return Type<&Account>() == capType
}
`)

Expand Down Expand Up @@ -9212,7 +9213,7 @@ func TestRuntimeWrappedErrorHandling(t *testing.T) {
import Foo from 0x1
transaction {
prepare(signer: &Account) {
prepare(signer: auth (Storage, Capabilities) &Account) {
signer.storage.save(<- Foo.createR(), to: /storage/r)
let cap = signer.capabilities.storage.issue<&Foo.R>(/storage/r)
signer.capabilities.publish(cap, at: /public/r)
Expand Down
20 changes: 10 additions & 10 deletions runtime/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func TestRuntimeTopShotBatchTransfer(t *testing.T) {
transaction {
prepare(signer: auth(Storage) &Account) {
prepare(signer: auth(Storage, Capabilities) &Account) {
signer.storage.save(
<-TopShot.createEmptyCollection(),
to: /storage/MomentCollection
Expand Down Expand Up @@ -1723,7 +1723,7 @@ func TestRuntimeResourceOwnerChange(t *testing.T) {
transaction {
prepare(
signer1: auth(Storage) &Account,
signer1: auth(Storage) &Account,
signer2: auth(Storage) &Account
) {
let value <- signer1.storage.load<@Test.R>(from: /storage/test)!
Expand Down Expand Up @@ -2123,8 +2123,8 @@ func TestRuntimeReferenceOwnerAccess(t *testing.T) {
transaction {
prepare(
accountA: auth(Storage) &Account,
accountB: auth(Storage) &Account
accountA: auth(Storage, Capabilities) &Account,
accountB: auth(Storage, Capabilities) &Account
) {
let testResource <- TestContract.makeTestResource()
let ref1 = &testResource as &TestContract.TestResource
Expand Down Expand Up @@ -3234,7 +3234,7 @@ func TestRuntimeStorageIteration(t *testing.T) {
import Test from 0x1
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
signer.storage.save("Hello, World!", to: /storage/first)
signer.storage.save(["one", "two", "three"], to: /storage/second)
signer.storage.save(Test.Foo(), to: /storage/third)
Expand Down Expand Up @@ -3264,7 +3264,7 @@ func TestRuntimeStorageIteration(t *testing.T) {
Script{
Source: []byte(`
transaction {
prepare(account: &Account) {
prepare(account: auth(Storage) &Account) {
var total = 0
account.forEachStored(fun (path: StoragePath, type: Type): Bool {
account.storage.borrow<&AnyStruct>(from: path)!
Expand Down Expand Up @@ -3358,7 +3358,7 @@ func TestRuntimeStorageIteration(t *testing.T) {
import Test from 0x1
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
signer.storage.save("Hello, World!", to: /storage/first)
signer.storage.save(["one", "two", "three"], to: /storage/second)
signer.storage.save(Test.Foo(), to: /storage/third)
Expand Down Expand Up @@ -3399,7 +3399,7 @@ func TestRuntimeStorageIteration(t *testing.T) {
Script{
Source: []byte(`
transaction {
prepare(account: &Account) {
prepare(account: auth(Storage) &Account) {
var total = 0
account.storage.forEachPublic(fun (path: PublicPath, type: Type): Bool {
account.capabilities.borrow<&AnyStruct>(path)!
Expand Down Expand Up @@ -3491,7 +3491,7 @@ func TestRuntimeStorageIteration(t *testing.T) {
Source: []byte(`
import Test from 0x1
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage, Capabilities) &Account) {
signer.storage.save("Hello, World!", to: /storage/first)
signer.storage.save(["one", "two", "three"], to: /storage/second)
signer.storage.save(Test.Foo(), to: /storage/third)
Expand Down Expand Up @@ -3623,7 +3623,7 @@ func TestRuntimeStorageIteration(t *testing.T) {
Source: []byte(`
import Test from 0x1
transaction {
prepare(signer: &Account) {
prepare(signer: auth(Storage) &Account) {
signer.storage.save("Hello, World!", to: /storage/first)
signer.storage.save(["one", "two", "three"], to: /storage/second)
signer.storage.save(Test.Foo(), to: /storage/third)
Expand Down

0 comments on commit 6395c0f

Please sign in to comment.