Skip to content

Commit

Permalink
Release 2.1.3 (#211)
Browse files Browse the repository at this point in the history
* Add smoke tests for each network

Signed-off-by: nikolay <[email protected]>

* Edit ci

Signed-off-by: nikolay <[email protected]>

* Bump versions

Signed-off-by: nikolay <[email protected]>

* Edit ci

Signed-off-by: nikolay <[email protected]>

* Edit ci

Signed-off-by: nikolay <[email protected]>

* Fix local node occasionally fails to start (#203)

* wait before generating accounts

Signed-off-by: georgi-l95 <[email protected]>

* bump sdk version

Signed-off-by: georgi-l95 <[email protected]>

* bump sdk version

Signed-off-by: georgi-l95 <[email protected]>

* test

Signed-off-by: georgi-l95 <[email protected]>

* check if network node is started

Signed-off-by: georgi-l95 <[email protected]>

Signed-off-by: georgi-l95 <[email protected]>

* Add environment readiness test flow (#188)

Add environment readiness test flow

Signed-off-by: georgi-l95 <[email protected]>

* Add feature flag for atomicCryptoTransfer (#210)

Signed-off-by: nikolay <[email protected]>

Signed-off-by: nikolay <[email protected]>

* bump version 2.1.3

Signed-off-by: georgi-l95 <[email protected]>

Signed-off-by: nikolay <[email protected]>
Signed-off-by: georgi-l95 <[email protected]>
Co-authored-by: nikolay <[email protected]>
  • Loading branch information
georgi-l95 and natanasow authored Oct 28, 2022
1 parent 2f05edb commit bc93b0f
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 9 deletions.
9 changes: 5 additions & 4 deletions configs/local.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"maxSizeKb": 2048,
"streamExtension": "rcd.gz",
"sidecarEnabled": true,
"nodeImageTag": "0.31.0",
"havegedImageTag": "0.31.0",
"nodeImageTag": "0.32.0-alpha.1",
"havegedImageTag": "0.32.0-alpha.1",
"uploaderImageTag": "0.7.0",
"mirrorImageTag": "0.67.0-rc1",
"relayImageTag": "0.9.0",
"relayImageTag": "0.10.0",
"mirrorNodeExplorerImageTag": "latest",
"timeout": "180s",
"pythonVersion": "python3.7",
Expand All @@ -30,6 +30,7 @@
"signatureFileVersion": 6,
"enableTraceabilityMigration": true,
"compressFilesOnCreation": true,
"sidecars": "CONTRACT_STATE_CHANGE,CONTRACT_BYTECODE"
"sidecars": "CONTRACT_STATE_CHANGE,CONTRACT_BYTECODE",
"atomicCryptoTransfer": true
}
}
18 changes: 16 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/hedera-local",
"version": "2.1.2",
"version": "2.1.3",
"description": "Developer tooling for running Local Hedera Network (Consensus + Mirror Nodes).",
"homepage": "https://github.com/hashgraph/hedera-local-node",
"repository": "github.com:hashgraph/hedera-local-node",
Expand All @@ -13,18 +13,22 @@
"bin": {
"hedera": "./cli.js"
},
"scripts": {
"test:readiness": "node src/utils/testNode.js"
},
"dependencies": {
"@hashgraph/hethers": "^1.1.2",
"@hashgraph/sdk": "2.18.5",
"blessed": "^0.1.81",
"blessed-contrib": "^4.11.0",
"dockerode": "^3.3.4",
"dotenv": "^16.0.3",
"ethers": "^5.6.9",
"js-yaml": "^4.1.0",
"mustache": "^4.2.0",
"rimraf": "^3.0.2",
"shelljs": "^0.8.5",
"yargs": "^17.5.1",
"mustache": "^4.2.0"
"yargs": "^17.5.1"
},
"devDependencies": {
"hardhat": "^2.11.2"
Expand Down
124 changes: 124 additions & 0 deletions src/utils/testNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
const {
Client,
PrivateKey,
AccountCreateTransaction,
AccountBalanceQuery,
Hbar,
TransferTransaction,
AccountId,
TransactionId,
TokenCreateTransaction
} = require("@hashgraph/sdk");
const axios = require('axios');
require("dotenv").config();

async function main() {
const myAccountId = process.env.RELAY_OPERATOR_ID_MAIN;
const myPrivateKey = process.env.RELAY_OPERATOR_KEY_MAIN;

if (myAccountId == null || myPrivateKey == null) {
throw new Error(
"Environment variables myAccountId and myPrivateKey must be present"
);
}
const node = { "127.0.0.1:50211": new AccountId(3) };
const client = Client.forNetwork(node).setMirrorNetwork("127.0.0.1:5600");
client.setOperator(myAccountId, myPrivateKey);

const newAccountId = await createAccount(client);
await transferHbar(client, myAccountId, newAccountId);

const { validStart } = await createHTSToken(client);
const transactionIdFormatted = `${myAccountId}-${validStart.replace(/\./g,'-')}`;
console.log(`- Mirror Node Explorer URL: http://localhost:9090/#/devnet/transaction/${transactionIdFormatted}`);
await getTransactionInformation(transactionIdFormatted);
}


const getTransactionInformation = async function(transactionIdFormatted) {
const url = "http://localhost:5551/api/v1/transactions/"+transactionIdFormatted
console.log('- Mirror Node Url: ' + url)
await sleep(5);
axios.get(url, {})
.then(function (response) {
console.log(response.data.transactions);
process.exit(0);
})
}

const createAccount = async function (client) {
const newAccountPrivateKey = await PrivateKey.generateED25519();
const newAccountPublicKey = newAccountPrivateKey.publicKey;

const newAccount = await new AccountCreateTransaction()
.setKey(newAccountPublicKey)
.setInitialBalance(Hbar.fromTinybars(1000))
.execute(client);

const getReceipt = await newAccount.getReceipt(client);
const newAccountId = getReceipt.accountId;

console.log("- New account ID is: " + newAccountId);

const accountBalance = await new AccountBalanceQuery()
.setAccountId(newAccountId)
.execute(client);

console.log(
"- New account balance is: " +
accountBalance.hbars.toTinybars() +
" tinybar."
);

return newAccountId;
}

const transferHbar = async function (client, myAccountId, newAccountId) {
await new TransferTransaction()
.addHbarTransfer(myAccountId, Hbar.fromTinybars(-10000))
.addHbarTransfer(newAccountId, Hbar.fromTinybars(10000))
.execute(client);

await sleep(5);

const balance = await new AccountBalanceQuery()
.setAccountId(newAccountId)
.execute(client);

console.log(
"- New account balance after transfer is: " +
balance.hbars.toTinybars() +
" tinybar."
);
}

const createHTSToken = async function(client) {
const expiration = new Date();
expiration.setDate(expiration.getDate() + 30);
const tokenCreate = await (await new TokenCreateTransaction()
.setTokenName("WrappedHedera")
.setTokenSymbol("WHBAR")
.setExpirationTime(expiration)
.setDecimals(8)
.setInitialSupply(200000000000)
.setTreasuryAccountId(client.operatorAccountId)
.setTransactionId(TransactionId.generate(client.operatorAccountId))
.setNodeAccountIds([client._network.getNodeAccountIdsForExecute()[0]]))
.setTransactionMemo('relay dapp test token create')
.execute(client);

const receipt = await tokenCreate.getReceipt(client);
const transactionId = tokenCreate.transactionId.toString();
const validStart = tokenCreate.transactionId.validStart.toString();
const tokenId = receipt.tokenId.toString();

console.log(`- HTS Token Deployed with id ${tokenId}, transactionId: ${transactionId}, valid start: ${validStart}`);

return { tokenId, transactionId, validStart };
};

const sleep = async function (seconds) {
await new Promise(r => setTimeout(r, seconds * 1000 ));
}

main();
1 change: 1 addition & 0 deletions templates/local/bootstrap.template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ hedera.recordStream.signatureFileVersion={{signatureFileVersion}}
hedera.recordStream.enableTraceabilityMigration={{enableTraceabilityMigration}}
hedera.recordStream.compressFilesOnCreation={{compressFilesOnCreation}}
contracts.sidecars={{sidecars}}
contracts.precompile.atomicCryptoTransfer.enabled={{atomicCryptoTransfer}}
{{/features}}

0 comments on commit bc93b0f

Please sign in to comment.