Compare commits

..

No commits in common. "68597ea7cc0ee6020a74d7ef88f64f0cfcfee892" and "fdde1bb979d437291e9fde6a92d44caa97f10408" have entirely different histories.

3 changed files with 23 additions and 6 deletions

View File

@ -125,6 +125,12 @@ func (h *MenuHandlers) Init(ctx context.Context, sym string, input []byte) (reso
h.st = h.pe.GetState()
h.ca = h.pe.GetMemory()
if len(input) == 0 {
// move to the top node
h.st.Code = []byte{}
}
sessionId, ok := ctx.Value("SessionId").(string)
if ok {
ctx = context.WithValue(ctx, "SessionId", sessionId)

View File

@ -175,6 +175,20 @@ func TestInit(t *testing.T) {
input: []byte("1"),
expectedResult: resource.Result{},
},
{
name: "Move to top node on empty input",
setup: func() (*MenuHandlers, context.Context) {
pe := persist.NewPersister(testStore).WithSession(sessionId).WithContent(st, ca)
h := &MenuHandlers{
flagManager: fm,
pe: pe,
}
st.Code = []byte("some pending bytecode")
return h, context.WithValue(ctx, "SessionId", sessionId)
},
input: []byte(""),
expectedResult: resource.Result{},
},
}
for _, tt := range tests {

View File

@ -10,7 +10,6 @@ import (
"git.defalsify.org/vise.git/resource"
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
sarafu_engine "git.grassecon.net/grassrootseconomics/sarafu-vise/engine"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
)
@ -25,7 +24,7 @@ type LocalHandlerService struct {
UserdataStore *db.Db
Cfg engine.Config
Rs resource.Resource
first resource.EntryFunc
first resource.EntryFunc
}
func NewLocalHandlerService(ctx context.Context, fp string, debug bool, dbResource *resource.DbResource, cfg engine.Config, rs resource.Resource) (*LocalHandlerService, error) {
@ -126,8 +125,7 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
}
func (ls *LocalHandlerService) GetEngine(cfg engine.Config, rs resource.Resource, pr *persist.Persister) engine.Engine {
se := sarafu_engine.NewSarafuEngine(cfg, rs)
en := se.Engine.(*engine.DefaultEngine)
en := engine.NewEngine(cfg, rs)
if ls.first != nil {
en = en.WithFirst(ls.first)
}
@ -135,6 +133,5 @@ func (ls *LocalHandlerService) GetEngine(cfg engine.Config, rs resource.Resource
if cfg.EngineDebug {
en = en.WithDebug(nil)
}
return se
return en
}