Skip to content

Commit

Permalink
Rename TestFramework's NewEmulatorBackend function to EmulatorBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Sep 25, 2023
1 parent 72bbfe1 commit 20a58ec
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion runtime/stdlib/test-framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
// This is used as a way to inject test provider dependencies dynamically.

type TestFramework interface {
NewEmulatorBackend() Blockchain
EmulatorBackend() Blockchain

ReadFile(string) (string, error)
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/stdlib/test_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ func (t *TestContractType) NewTestContract(
initializerTypes := t.InitializerTypes
emulatorBackend := t.emulatorBackendType.newEmulatorBackend(
inter,
testFramework.NewEmulatorBackend(),
testFramework.EmulatorBackend(),
interpreter.EmptyLocationRange,
)
value, err := inter.InvokeFunctionValue(
Expand Down
42 changes: 21 additions & 21 deletions runtime/stdlib/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (

func newTestContractInterpreter(t *testing.T, code string) (*interpreter.Interpreter, error) {
testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{}
},
}
Expand Down Expand Up @@ -2070,7 +2070,7 @@ func TestBlockchain(t *testing.T) {
eventsInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
events: func(inter *interpreter.Interpreter, eventType interpreter.StaticType) interpreter.Value {
eventsInvoked = true
Expand Down Expand Up @@ -2117,7 +2117,7 @@ func TestBlockchain(t *testing.T) {
eventsInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
events: func(inter *interpreter.Interpreter, eventType interpreter.StaticType) interpreter.Value {
eventsInvoked = true
Expand Down Expand Up @@ -2161,7 +2161,7 @@ func TestBlockchain(t *testing.T) {
resetInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
reset: func(height uint64) {
resetInvoked = true
Expand Down Expand Up @@ -2194,7 +2194,7 @@ func TestBlockchain(t *testing.T) {
resetInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
reset: func(height uint64) {
resetInvoked = true
Expand Down Expand Up @@ -2226,7 +2226,7 @@ func TestBlockchain(t *testing.T) {
moveTimeInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
moveTime: func(timeDelta int64) {
moveTimeInvoked = true
Expand Down Expand Up @@ -2262,7 +2262,7 @@ func TestBlockchain(t *testing.T) {
moveTimeInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
moveTime: func(timeDelta int64) {
moveTimeInvoked = true
Expand Down Expand Up @@ -2295,7 +2295,7 @@ func TestBlockchain(t *testing.T) {
moveTimeInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
moveTime: func(timeDelta int64) {
moveTimeInvoked = true
Expand Down Expand Up @@ -2324,7 +2324,7 @@ func TestBlockchain(t *testing.T) {
createSnapshotInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
createSnapshot: func(name string) error {
createSnapshotInvoked = true
Expand Down Expand Up @@ -2359,7 +2359,7 @@ func TestBlockchain(t *testing.T) {
createSnapshotInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
createSnapshot: func(name string) error {
createSnapshotInvoked = true
Expand Down Expand Up @@ -2395,7 +2395,7 @@ func TestBlockchain(t *testing.T) {
loadSnapshotInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
createSnapshot: func(name string) error {
assert.Equal(t, "adminCreated", name)
Expand Down Expand Up @@ -2436,7 +2436,7 @@ func TestBlockchain(t *testing.T) {
loadSnapshotInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
createSnapshot: func(name string) error {
assert.Equal(t, "adminCreated", name)
Expand Down Expand Up @@ -2482,7 +2482,7 @@ func TestBlockchain(t *testing.T) {
deployContractInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
deployContract: func(
inter *interpreter.Interpreter,
Expand Down Expand Up @@ -2535,7 +2535,7 @@ func TestBlockchain(t *testing.T) {
deployContractInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
deployContract: func(
inter *interpreter.Interpreter,
Expand Down Expand Up @@ -2575,7 +2575,7 @@ func TestBlockchain(t *testing.T) {
getAccountInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
getAccount: func(address interpreter.AddressValue) (*stdlib.Account, error) {
getAccountInvoked = true
Expand Down Expand Up @@ -2620,7 +2620,7 @@ func TestBlockchain(t *testing.T) {
getAccountInvoked := false

testFramework := &mockedTestFramework{
newEmulatorBackend: func() stdlib.Blockchain {
emulatorBackend: func() stdlib.Blockchain {
return &mockedBlockchain{
getAccount: func(address interpreter.AddressValue) (*stdlib.Account, error) {
getAccountInvoked = true
Expand Down Expand Up @@ -2649,18 +2649,18 @@ func TestBlockchain(t *testing.T) {
}

type mockedTestFramework struct {
newEmulatorBackend func() stdlib.Blockchain
readFile func(s string) (string, error)
emulatorBackend func() stdlib.Blockchain
readFile func(s string) (string, error)
}

var _ stdlib.TestFramework = &mockedTestFramework{}

func (m mockedTestFramework) NewEmulatorBackend() stdlib.Blockchain {
if m.newEmulatorBackend == nil {
func (m mockedTestFramework) EmulatorBackend() stdlib.Blockchain {
if m.emulatorBackend == nil {
panic("'NewEmulatorBackend' is not implemented")
}

return m.newEmulatorBackend()
return m.emulatorBackend()
}

func (m mockedTestFramework) ReadFile(fileName string) (string, error) {
Expand Down

0 comments on commit 20a58ec

Please sign in to comment.