-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:Argus-Labs/world-engine into brian/…
…world-485-make-sure-querygo-api-is-protected-with-tests
- Loading branch information
Showing
15 changed files
with
175 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cardinal_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"gotest.tools/v3/assert" | ||
"pkg.world.dev/world-engine/cardinal" | ||
"pkg.world.dev/world-engine/cardinal/testutils" | ||
) | ||
|
||
func TestCanRemoveEntity(t *testing.T) { | ||
world, _ := testutils.MakeWorldAndTicker(t) | ||
|
||
assert.NilError(t, cardinal.RegisterComponent[Alpha](world)) | ||
|
||
testWorldCtx := testutils.WorldToWorldContext(world) | ||
ids, err := cardinal.CreateMany(testWorldCtx, 2, Alpha{}) | ||
assert.NilError(t, err) | ||
|
||
removeID := ids[0] | ||
keepID := ids[1] | ||
|
||
assert.NilError(t, cardinal.Remove(testWorldCtx, removeID)) | ||
|
||
search, err := testWorldCtx.NewSearch(cardinal.Exact(Alpha{})) | ||
assert.NilError(t, err) | ||
count := 0 | ||
assert.NilError(t, search.Each(testWorldCtx, func(id cardinal.EntityID) bool { | ||
assert.Equal(t, id, keepID) | ||
count++ | ||
return true | ||
})) | ||
assert.Equal(t, 1, count) | ||
|
||
// We should not be able to find the component for the removed ID | ||
_, err = cardinal.GetComponent[Alpha](testWorldCtx, removeID) | ||
assert.Check(t, err != nil) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cardinal | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"testing" | ||
|
||
"pkg.world.dev/world-engine/chain/x/shard/types" | ||
"pkg.world.dev/world-engine/sign" | ||
) | ||
|
||
type DummyAdapter struct{} | ||
|
||
func (d *DummyAdapter) Submit(_ context.Context, _ *sign.SignedPayload, _, _ uint64) error { | ||
return nil | ||
} | ||
|
||
func (d *DummyAdapter) QueryTransactions(_ context.Context, _ *types.QueryTransactionsRequest, | ||
) (*types.QueryTransactionsResponse, error) { | ||
return nil, errors.New("this function should never get called") | ||
} | ||
|
||
func TestOptionFunctionSignatures(_ *testing.T) { | ||
// This test is designed to keep API compatibility. If a compile error happens here it means a function signature to | ||
// public facing functions was changed. | ||
WithAdapter(&DummyAdapter{}) | ||
WithReceiptHistorySize(1) | ||
WithNamespace("blah") | ||
WithPort("4040") | ||
WithDisableSignatureVerification() //nolint:staticcheck //this test just looks for compile errors | ||
WithPrettyLog() //nolint:staticcheck //this test just looks for compile errors | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.