From 034b4aa2ac2f106f18c4bcd1e3a2ae5663f0b6a5 Mon Sep 17 00:00:00 2001 From: Verin1005 Date: Tue, 23 Jul 2024 09:45:55 +0000 Subject: [PATCH] uncomment --- .../ts-tests/integration-tests/dr_vc.test.ts | 160 +++++++++--------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/tee-worker/ts-tests/integration-tests/dr_vc.test.ts b/tee-worker/ts-tests/integration-tests/dr_vc.test.ts index b9a011c5b1..0a38d8c587 100644 --- a/tee-worker/ts-tests/integration-tests/dr_vc.test.ts +++ b/tee-worker/ts-tests/integration-tests/dr_vc.test.ts @@ -48,86 +48,86 @@ describe('Test Vc (direct request)', function () { aliceSubstrateIdentity = await context.web3Wallets.substrate.Alice.getIdentity(context); }); - // step('linking identities (alice)', async function () { - // let currentNonce = (await getSidechainNonce(context, aliceSubstrateIdentity)).toNumber(); - // const getNextNonce = () => currentNonce++; - - // const twitterNonce = getNextNonce(); - // const twitterIdentity = await buildIdentityHelper('mock_user', 'Twitter', context); - // const twitterValidation = await buildWeb2Validation({ - // identityType: 'Twitter', - // context, - // signerIdentitity: aliceSubstrateIdentity, - // linkIdentity: twitterIdentity, - // verificationType: 'PublicTweet', - // validationNonce: twitterNonce, - // }); - // const twitterNetworks = context.api.createType('Vec', []); - // linkIdentityRequestParams.push({ - // nonce: twitterNonce, - // identity: twitterIdentity, - // validation: twitterValidation, - // networks: twitterNetworks, - // }); - - // const evmNonce = getNextNonce(); - - // const evmIdentity = await context.web3Wallets.evm.Alice.getIdentity(context); - // const evmValidation = await buildValidations( - // context, - // aliceSubstrateIdentity, - // evmIdentity, - // evmNonce, - // 'ethereum', - // context.web3Wallets.evm.Alice - // ); - // const evmNetworks = context.api.createType('Vec', ['Ethereum', 'Bsc']); - // linkIdentityRequestParams.push({ - // nonce: evmNonce, - // identity: evmIdentity, - // validation: evmValidation, - // networks: evmNetworks, - // }); - - // const bitcoinNonce = getNextNonce(); - - // const bitcoinIdentity = await context.web3Wallets.bitcoin.Alice.getIdentity(context); - // console.log('bitcoin id: ', bitcoinIdentity.toHuman()); - // const bitcoinValidation = await buildValidations( - // context, - // aliceSubstrateIdentity, - // bitcoinIdentity, - // bitcoinNonce, - // 'bitcoin', - // context.web3Wallets.bitcoin.Alice - // ); - // const bitcoinNetworks = context.api.createType('Vec', ['BitcoinP2tr']); - // linkIdentityRequestParams.push({ - // nonce: bitcoinNonce, - // identity: bitcoinIdentity, - // validation: bitcoinValidation, - // networks: bitcoinNetworks, - // }); - - // for (const { nonce, identity, validation, networks } of linkIdentityRequestParams) { - // const requestIdentifier = `0x${randomBytes(32).toString('hex')}`; - // const linkIdentityCall = await createSignedTrustedCallLinkIdentity( - // context.api, - // context.mrEnclave, - // context.api.createType('Index', nonce), - // context.web3Wallets.substrate.Alice, - // aliceSubstrateIdentity, - // identity.toHex(), - // validation.toHex(), - // networks.toHex(), - // context.api.createType('Option', aesKey).toHex(), - // requestIdentifier - // ); - - // const res = await sendRequestFromTrustedCall(context, teeShieldingKey, linkIdentityCall); - // await assertIsInSidechainBlock('linkIdentityCall', res); - // } - // }); + step('linking identities (alice)', async function () { + let currentNonce = (await getSidechainNonce(context, aliceSubstrateIdentity)).toNumber(); + const getNextNonce = () => currentNonce++; + + const twitterNonce = getNextNonce(); + const twitterIdentity = await buildIdentityHelper('mock_user', 'Twitter', context); + const twitterValidation = await buildWeb2Validation({ + identityType: 'Twitter', + context, + signerIdentitity: aliceSubstrateIdentity, + linkIdentity: twitterIdentity, + verificationType: 'PublicTweet', + validationNonce: twitterNonce, + }); + const twitterNetworks = context.api.createType('Vec', []); + linkIdentityRequestParams.push({ + nonce: twitterNonce, + identity: twitterIdentity, + validation: twitterValidation, + networks: twitterNetworks, + }); + + const evmNonce = getNextNonce(); + + const evmIdentity = await context.web3Wallets.evm.Alice.getIdentity(context); + const evmValidation = await buildValidations( + context, + aliceSubstrateIdentity, + evmIdentity, + evmNonce, + 'ethereum', + context.web3Wallets.evm.Alice + ); + const evmNetworks = context.api.createType('Vec', ['Ethereum', 'Bsc']); + linkIdentityRequestParams.push({ + nonce: evmNonce, + identity: evmIdentity, + validation: evmValidation, + networks: evmNetworks, + }); + + const bitcoinNonce = getNextNonce(); + + const bitcoinIdentity = await context.web3Wallets.bitcoin.Alice.getIdentity(context); + console.log('bitcoin id: ', bitcoinIdentity.toHuman()); + const bitcoinValidation = await buildValidations( + context, + aliceSubstrateIdentity, + bitcoinIdentity, + bitcoinNonce, + 'bitcoin', + context.web3Wallets.bitcoin.Alice + ); + const bitcoinNetworks = context.api.createType('Vec', ['BitcoinP2tr']); + linkIdentityRequestParams.push({ + nonce: bitcoinNonce, + identity: bitcoinIdentity, + validation: bitcoinValidation, + networks: bitcoinNetworks, + }); + + for (const { nonce, identity, validation, networks } of linkIdentityRequestParams) { + const requestIdentifier = `0x${randomBytes(32).toString('hex')}`; + const linkIdentityCall = await createSignedTrustedCallLinkIdentity( + context.api, + context.mrEnclave, + context.api.createType('Index', nonce), + context.web3Wallets.substrate.Alice, + aliceSubstrateIdentity, + identity.toHex(), + validation.toHex(), + networks.toHex(), + context.api.createType('Option', aesKey).toHex(), + requestIdentifier + ); + + const res = await sendRequestFromTrustedCall(context, teeShieldingKey, linkIdentityCall); + await assertIsInSidechainBlock('linkIdentityCall', res); + } + }); mockBatchAssertion.forEach(({ description, assertion }) => { step(`request vc payload: ${JSON.stringify(assertion)} (alice)`, async function () {