forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: speed up e2e * fix for mac osx * Bump to resolve conflicts & supress warning * Add rpc def when initialize to suppress warning * Removes unnecessary beacon relay check. Adds total time printout for start-services at the end of the script. (paritytech#750) Co-authored-by: claravanstaden <Cats 4 life!> * minor fix Co-authored-by: Clara van Staden <[email protected]>
- Loading branch information
1 parent
0330bdd
commit fc11987
Showing
20 changed files
with
948 additions
and
511 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
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,18 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
source scripts/set-env.sh | ||
|
||
hack_lodestar() { | ||
preset_minimal_phase0_file="$core_dir/node_modules/.pnpm/@lodestar+params@$lodestar_version/node_modules/@lodestar/params/lib/presets/minimal/phase0.js" | ||
if [[ "$OSTYPE" =~ ^darwin ]] | ||
then | ||
sed_cmd=gsed | ||
else | ||
sed_cmd=sed | ||
fi | ||
echo "change variable SLOTS_PER_EPOCH from 8 to 4" | ||
$sed_cmd -i "s/SLOTS_PER_EPOCH: 8/SLOTS_PER_EPOCH: 4/g" $preset_minimal_phase0_file | ||
} | ||
|
||
hack_lodestar |
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,45 @@ | ||
const Web3 = require('web3'); | ||
|
||
const BigNumber = require('bignumber.js'); | ||
|
||
const { expect } = require("chai") | ||
.use(require("chai-as-promised")) | ||
.use(require("chai-bignumber")(BigNumber)); | ||
|
||
const { treasuryAddressSS58, polkadotSenderSS58Alice, | ||
polkadotRecipientSS58, polkadotRecipient, bootstrap } = require('../src/fixtures'); | ||
|
||
const { ChannelId } = require("../src/helpers"); | ||
|
||
describe('Bootstrap-Ethereum-to-Substrate', function () { | ||
let ethClient, subClient; | ||
|
||
before(async function () { | ||
const clients = await bootstrap(); | ||
ethClient = clients.ethClient; | ||
subClient = clients.subClient; | ||
this.testParaEthAssetId = 0; | ||
}); | ||
|
||
it('should transfer ETH from Ethereum to Substrate (basic channel)', async function () { | ||
const amount = BigNumber(Web3.utils.toWei('0.001', "ether")); | ||
const ethAccount = ethClient.accounts[1]; | ||
|
||
const subBalances = await subClient.subscribeAssetsAccountBalances( | ||
this.testParaEthAssetId, polkadotRecipientSS58, 2 | ||
); | ||
|
||
const beforeEthBalance = await ethClient.getEthBalance(ethAccount); | ||
const beforeSubBalance = await subBalances[0]; | ||
|
||
const { gasCost } = await ethClient.lockETH(ethAccount, amount, polkadotRecipient, ChannelId.BASIC, 0, 0); | ||
|
||
const afterEthBalance = await ethClient.getEthBalance(ethAccount); | ||
const afterSubBalance = await subBalances[1]; | ||
|
||
expect(beforeEthBalance.minus(afterEthBalance)).to.be.bignumber.equal(amount.plus(gasCost)); | ||
expect(afterSubBalance.minus(beforeSubBalance)).to.be.bignumber.equal(amount); | ||
// conservation of value | ||
expect(beforeEthBalance.plus(beforeSubBalance)).to.be.bignumber.equal(afterEthBalance.plus(afterSubBalance).plus(gasCost)); | ||
}); | ||
}); |
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,42 @@ | ||
const Web3 = require('web3'); | ||
|
||
const BigNumber = require('bignumber.js'); | ||
|
||
const { expect } = require("chai") | ||
.use(require("chai-as-promised")) | ||
.use(require("chai-bignumber")(BigNumber)); | ||
|
||
const { treasuryAddressSS58, polkadotSenderSS58Alice, | ||
polkadotRecipientSS58, polkadotRecipient, bootstrap } = require('../src/fixtures'); | ||
|
||
const { ChannelId } = require("../src/helpers"); | ||
|
||
describe('Bootstrap-Substrate-to-Ethereum', function () { | ||
let ethClient, subClient; | ||
|
||
before(async function () { | ||
const clients = await bootstrap(); | ||
ethClient = clients.ethClient; | ||
subClient = clients.subClient; | ||
this.testParaEthAssetId = 0; | ||
}); | ||
|
||
it('should transfer DOT from Substrate to Ethereum (basic channel)', async function () { | ||
const amount = BigNumber('100000000000000'); // 100 DOT (12 decimal places in this environment) | ||
const amountWrapped = BigNumber(Web3.utils.toWei('100', "ether")); // 100 SnowDOT (18 decimal places) | ||
const ethAccount = ethClient.accounts[1]; | ||
|
||
const beforeEthBalance = await ethClient.getDotBalance(ethAccount); | ||
const beforeSubBalanceAlice = await subClient.queryAccountBalance(polkadotSenderSS58Alice); | ||
|
||
// lock DOT using basic channel | ||
await subClient.lockDOT(subClient.alice, ethAccount, amount.toFixed(), ChannelId.BASIC) | ||
await ethClient.waitForNextEventData({ appName: 'appDOT', eventName: 'Minted' }); | ||
|
||
const afterEthBalance = await ethClient.getDotBalance(ethAccount); | ||
const afterSubBalanceAlice = await subClient.queryAccountBalance(polkadotSenderSS58Alice); | ||
|
||
expect(afterEthBalance.minus(beforeEthBalance)).to.be.bignumber.equal(amountWrapped); | ||
expect(beforeSubBalanceAlice.minus(afterSubBalanceAlice)).to.be.bignumber.greaterThan(amount); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.