Skip to main content

Testing

All functionality is tested in some script in /test. Please see those scripts for examples on functionality not documented.

info

Testing is only possible with a development Lattice, which GridPlus does not distribute publicly. Therefore, if you do not have a development Lattice, you will not be able to run many of these tests.**

Setting up a test connectionโ€‹

Only one test can be run against an unpaired Lattice: npm run test. Therefore this must be run before running any other tests. If you wish to run additional tests, you need to specify the following:

env REUSE_KEY=1 npm run test

The REUSE_KEY will save the connection locally so you can run future tests. Running this test will ask for your device ID and will go through the pairing process. After pairing, the rest of the script will test a broad range of SDK functionality.

To use the connection you've established with any test (including this initial one), you need to include your DEVICE_ID as an env argument:

env DEVICE_ID='mydeviceid' npm run test

Global env Optionsโ€‹

The following options can be used after env with any test.

ParamOptionsDescription
REUSE_KEYMust be 1Indicates we will be creating a new pairing with a Lattice and stashing that connection
DEVICE_IDA six character stringThe device ID of the target Lattice.
ENC_PWDevice-level password set by the user, used when exporting encrypted data.
ETHERSCAN_KEYAny stringAPI key for making requests to Etherscan. This is needed specifically for e2e-sign-evm-abi.
nameAny 5-25 character string (default="SDK Test")The name of the pairing you will create
baseUrlAny URL (default="https://signing.gridpl.us")URL describing where to send HTTP requests. Should be changed if your Lattice is on non-default message routing infrastructure.

Setting up the .env fileโ€‹

Alternatively, you may input env options into a .env file to make it easier to run scripts. To create your .env file, follow these steps:

  1. Copy the .env.template file.
  2. Rename the .env.template file to .env.
  3. Update the desired params in that file, probably your DEVICE_ID.

Firmware Test Runnerโ€‹

Several tests require dev Lattice firmware with the following flag in the root CMakeLists.txt:

FEATURE_TEST_RUNNER=1

See table in the next section.

Reference: Tests and Optionsโ€‹

You can run the following tests with npm run <test name>.

TestDescriptionRequires FEATURE_TEST_RUNNER=1
testRuns integration tests. Does not use Lattice.No
test-unitRuns SDK unit tests. Does not use Lattice.No
e2eRuns all end-to-end tests.Yes
e2e-btcTests BTC signatures (legacy signing)Yes
e2e-ethTests EIP712 and personal_sign messages (legacy signing)No
e2e-genTests seveal Lattice message routes and some SDK functionality. Bit of a legacy test but still useful.No
e2e-kvTests KV-files, which are used primarily for tags.No
e2e-neTests non-exportable seeded SafeCards (legacy).No
e2e-signRuns all signing tests.Yes
e2e-sign-blsTests BLS signatures and key derivations.Yes
e2e-sign-determinismTests determinism of signatures using known seed loading.Yes
e2e-sign-evm-abiTests ABI decoding and fetching for EVM transactions.Yes
e2e-sign-evm-txTests EVM transaction types.Yes
e2e-sign-solanaTests Solana transactions and address derivation.Yes
e2e-sign-unformattedTests signing unformatted payloads (ASCII or hex strings).Yes
e2e-wjTests wallet jobs, validating path derivations, seed management, etc.Yes