-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more ways to read scheduled enclave #2620
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d893864
Add bin subcommand and rpc command
Traf333 ab3d601
Merge branch 'dev' into p-644-add-more-ways-to-read-scheduled-enclave
outofxxx a12701a
cleanup
Traf333 ee61e93
remove sleep duration
Traf333 7a0f958
Merge branch 'dev' into p-644-add-more-ways-to-read-scheduled-enclave
Traf333 9fc4103
revert ts script
Traf333 e387e06
fmt
Traf333 49d157e
Merge branch 'dev' into p-644-add-more-ways-to-read-scheduled-enclave
Traf333 9d37b62
Merge branch 'dev' into p-644-add-more-ways-to-read-scheduled-enclave
Traf333 5769b45
remove usage from binary
Traf333 78fb3d0
Merge branch 'dev' into p-644-add-more-ways-to-read-scheduled-enclave
Traf333 0774b9f
clippy fix
Traf333 a07c704
Merge branch 'dev' into p-644-add-more-ways-to-read-scheduled-enclave
Traf333 56e32fa
add integration tests
Traf333 ade310d
copy rpc to bitacross
Traf333 c845542
cleanup
Traf333 43a4574
clippy fix
Traf333 8c4fb31
Merge branch 'dev' into p-644-add-more-ways-to-read-scheduled-enclave
Traf333 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,24 @@ | ||
services: | ||
lit-scheduled-enclave-test: | ||
image: litentry/litentry-cli:latest | ||
container_name: litentry-scheduled-enclave-test | ||
volumes: | ||
- ../ts-tests:/ts-tests | ||
- ../client-api:/client-api | ||
- ../cli:/usr/local/worker-cli | ||
build: | ||
context: .. | ||
dockerfile: build.Dockerfile | ||
target: deployed-client | ||
depends_on: | ||
litentry-node: | ||
condition: service_healthy | ||
litentry-worker-1: | ||
condition: service_healthy | ||
networks: | ||
- litentry-test-network | ||
entrypoint: "bash -c '/usr/local/worker-cli/lit_ts_integration_test.sh scheduled_enclave.test.ts 2>&1' " | ||
restart: "no" | ||
networks: | ||
litentry-test-network: | ||
driver: bridge |
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
84 changes: 84 additions & 0 deletions
84
tee-worker/ts-tests/integration-tests/scheduled_enclave.test.ts
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,84 @@ | ||
import { KeyObject } from 'crypto'; | ||
import { step } from 'mocha-steps'; | ||
import { initIntegrationTestContext } from './common/utils'; | ||
import { getTeeShieldingKey } from './common/di-utils'; | ||
import type { IntegrationTestContext, JsonRpcRequest } from './common/common-types'; | ||
import { decodeRpcBytesAsString, sendRequest } from './common/call'; | ||
import type { CorePrimitivesIdentity } from 'parachain-api'; | ||
import { assert } from 'chai'; | ||
import { createJsonRpcRequest, nextRequestId } from './common/helpers'; | ||
|
||
describe('Scheduled Enclave', function () { | ||
let context: IntegrationTestContext = undefined as any; | ||
let teeShieldingKey: KeyObject = undefined as any; | ||
let aliceSubstrateIdentity: CorePrimitivesIdentity = undefined as any; | ||
|
||
this.timeout(6000000); | ||
|
||
before(async () => { | ||
context = await initIntegrationTestContext( | ||
process.env.WORKER_ENDPOINT!, // @fixme evil assertion; centralize env access | ||
process.env.NODE_ENDPOINT! // @fixme evil assertion; centralize env access | ||
); | ||
teeShieldingKey = await getTeeShieldingKey(context); | ||
aliceSubstrateIdentity = await context.web3Wallets.substrate.Alice.getIdentity(context); | ||
}); | ||
|
||
step('state of scheduled enclave list', async function () { | ||
const request = createJsonRpcRequest('state_getScheduledEnclave', undefined, nextRequestId(context)); | ||
const response = await sendRequest(context.tee, request, context.api); | ||
const scheduledEnclaveList = context.api.createType('Vec<(u64, [u8; 32])>', response.value).toJSON() as [ | ||
number, | ||
string | ||
][]; | ||
|
||
assert.equal(1, scheduledEnclaveList.length); | ||
|
||
const [blockNumber, mrEnclave] = scheduledEnclaveList[0]; | ||
assert.equal(blockNumber, 0); | ||
assert.equal(mrEnclave, context.mrEnclave); | ||
}); | ||
|
||
step('setting new scheduled enclave', async function () { | ||
const buildRequest = (method: string, params?: any[]) => | ||
createJsonRpcRequest(method, params, nextRequestId(context)); | ||
const callRPC = async (request: JsonRpcRequest) => sendRequest(context.tee, request, context.api); | ||
|
||
let response = await callRPC(buildRequest('state_getScheduledEnclave')); | ||
let scheduledEnclaveList = context.api.createType('Vec<(u64, [u8; 32])>', response.value).toJSON() as [ | ||
number, | ||
string | ||
][]; | ||
|
||
assert.equal(scheduledEnclaveList.length, 1); | ||
|
||
// set new mrenclave | ||
let setEnclaveResponse = await callRPC( | ||
buildRequest('state_setScheduledEnclave', [20, 'some invalid mrenclave']) | ||
); | ||
assert.include(decodeRpcBytesAsString(setEnclaveResponse.value), 'Failed to decode mrenclave'); | ||
|
||
setEnclaveResponse = await callRPC(buildRequest('state_setScheduledEnclave', [20, '48656c6c6f20776f726c6421'])); | ||
assert.include( | ||
decodeRpcBytesAsString(setEnclaveResponse.value), | ||
'mrenclave len mismatch, expected 32 bytes long' | ||
); | ||
|
||
// valid mutation | ||
const validParams = [20, '97f516a61ff59c5eab74b8a9b1b7273d6986b9c0e6c479a4010e22402ca7cee6']; | ||
await callRPC(buildRequest('state_setScheduledEnclave', validParams)); | ||
|
||
// checking mutated state | ||
response = await callRPC(buildRequest('state_getScheduledEnclave')); | ||
scheduledEnclaveList = context.api.createType('Vec<(u64, [u8; 32])>', response.value).toJSON() as [ | ||
number, | ||
string | ||
][]; | ||
|
||
assert.equal(scheduledEnclaveList.length, 2); | ||
|
||
const [blockNumber, mrEnclave] = scheduledEnclaveList[1]; | ||
assert.equal(blockNumber, validParams[0]); | ||
assert.equal(mrEnclave, `0x${validParams[1]}`); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we define the type and then cast it to
any
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question 🤔 this one was copy-paste from another test. I just created chore task to cleanup our tests, as I've also seen some fixme's were copied from one test to another