/
testExecutorElrondTestnet.go
44 lines (37 loc) · 1.3 KB
/
testExecutorElrondTestnet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
worldhook "github.com/ElrondNetwork/elrond-vm-util/mock-hook-blockchain"
cryptohook "github.com/ElrondNetwork/elrond-vm-util/mock-hook-crypto"
ij "github.com/ElrondNetwork/elrond-vm-util/test-util/vmtestjson"
eiele "github.com/ElrondNetwork/elrond-vm/iele/elrond/node/endpoint"
)
type elrondTestnetIeleTestExecutor struct {
tracePretty bool
vm *eiele.ElrondIeleVM
world *worldhook.BlockchainHookMock
}
func newElrondTestnetIeleTestExecutor(tracePretty bool) *elrondTestnetIeleTestExecutor {
return &elrondTestnetIeleTestExecutor{
tracePretty: tracePretty,
vm: nil,
world: worldhook.NewMock(),
}
}
// ProcessCode takes the iele file path, assembles it and yields the bytecode.
func (te *elrondTestnetIeleTestExecutor) ProcessCode(testPath string, value string) (string, error) {
return assembleIeleCode(testPath, value)
}
// Run executes an individual Iele test.
func (te *elrondTestnetIeleTestExecutor) Run(test *ij.Test) error {
if te.vm == nil {
te.vm = eiele.NewElrondIeleVM(
eiele.TestVMType, eiele.ElrondDefault,
te.world, cryptohook.KryptoHookMockInstance)
te.vm.SetSignedArguments() // these tests assume signed arguments
if te.tracePretty {
te.vm.SetTracePretty()
}
}
err := runTestElrond(test, te.vm, te.world)
return err
}