Skip to content

Commit

Permalink
refactor(logic): move bootstrap to its own package
Browse files Browse the repository at this point in the history
...to avoir circular dependencies when testing
  • Loading branch information
ccamel committed Mar 21, 2023
1 parent a58991c commit a543e4a
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package interpreter
package bootstrap

import _ "embed"

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion x/logic/keeper/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ichiban/prolog"
"github.com/okp4/okp4d/x/logic/interpreter"
"github.com/okp4/okp4d/x/logic/interpreter/bootstrap"
"github.com/okp4/okp4d/x/logic/types"
"github.com/okp4/okp4d/x/logic/util"
)
Expand Down Expand Up @@ -97,7 +98,7 @@ func (k Keeper) newInterpreter(ctx goctx.Context) (*prolog.Interpreter, error) {
interpreted, err := interpreter.New(
ctx,
util.NonZeroOrDefault(interpreterParams.GetRegisteredPredicates(), interpreter.RegistryNames),
util.NonZeroOrDefault(interpreterParams.GetBootstrap(), interpreter.Bootstrap()),
util.NonZeroOrDefault(interpreterParams.GetBootstrap(), bootstrap.Bootstrap()),
sdkctx.GasMeter(),
k.fsProvider(ctx),
)
Expand Down
2 changes: 1 addition & 1 deletion x/logic/predicate/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestBech32(t *testing.T) {
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())

Convey("and a vm", func() {
interpreter := testutil.NewInterpreterMust(ctx)
interpreter := testutil.NewLightInterpreterMust(ctx)
interpreter.Register2(engine.NewAtom("bech32_address"), Bech32Address)

err := interpreter.Compile(ctx, tc.program)
Expand Down
2 changes: 1 addition & 1 deletion x/logic/predicate/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func TestBank(t *testing.T) {
Return(tc.balances)

Convey("and a vm", func() {
interpreter := testutil.NewInterpreterMust(ctx)
interpreter := testutil.NewLightInterpreterMust(ctx)
interpreter.Register2(engine.NewAtom("bank_balances"), BankBalances)
interpreter.Register2(engine.NewAtom("bank_spendable_balances"), BankSpendableBalances)
interpreter.Register2(engine.NewAtom("bank_locked_balances"), BankLockedBalances)
Expand Down
2 changes: 1 addition & 1 deletion x/logic/predicate/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestBlock(t *testing.T) {
ctx := sdk.NewContext(stateStore, tc.header, false, log.NewNopLogger())

Convey("and a vm", func() {
interpreter := testutil.NewInterpreterMust(ctx)
interpreter := testutil.NewLightInterpreterMust(ctx)
interpreter.Register1(engine.NewAtom("block_height"), BlockHeight)
interpreter.Register1(engine.NewAtom("block_time"), BlockTime)
testutil.CompileMust(ctx, interpreter, fmt.Sprintf("test :- %s.", tc.implication))
Expand Down
2 changes: 1 addition & 1 deletion x/logic/predicate/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestChainID(t *testing.T) {
ctx := sdk.NewContext(stateStore, tc.header, false, log.NewNopLogger())

Convey("and an interpreter", func() {
interpreter := testutil.NewInterpreterMust(ctx)
interpreter := testutil.NewLightInterpreterMust(ctx)
interpreter.Register1(engine.NewAtom("chain_id"), ChainID)
testutil.CompileMust(ctx, interpreter, fmt.Sprintf("test :- %s.", tc.implication))

Expand Down
2 changes: 1 addition & 1 deletion x/logic/predicate/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ H == [2252,222,43,46,219,165,107,244,8,96,31,183,33,254,155,92,51,141,16,238,66,
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())

Convey("and a vm", func() {
interpreter := testutil.NewInterpreterMust(ctx)
interpreter := testutil.NewLightInterpreterMust(ctx)
interpreter.Register2(engine.NewAtom("sha_hash"), SHAHash)
interpreter.Register2(engine.NewAtom("hex_bytes"), HexBytes)

Expand Down
2 changes: 1 addition & 1 deletion x/logic/predicate/did_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestDID(t *testing.T) {
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())

Convey("and a vm", func() {
interpreter := testutil.NewInterpreterMust(ctx)
interpreter := testutil.NewLightInterpreterMust(ctx)
interpreter.Register2(engine.NewAtom("did_components"), DIDComponents)

err := interpreter.Compile(ctx, tc.program)
Expand Down

0 comments on commit a543e4a

Please sign in to comment.