[#1654] adm: Make 'morph-init' idempotent
All checks were successful
DCO action / DCO (pull_request) Successful in 35s
Vulncheck / Vulncheck (pull_request) Successful in 59s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m21s
Build / Build Components (pull_request) Successful in 1m26s
Tests and linters / Staticcheck (pull_request) Successful in 2m39s
Tests and linters / Lint (pull_request) Successful in 2m45s
Tests and linters / Run gofumpt (pull_request) Successful in 3m4s
Tests and linters / Tests (pull_request) Successful in 3m13s
Tests and linters / Tests with -race (pull_request) Successful in 3m43s
Tests and linters / gopls check (pull_request) Successful in 3m44s

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2025-02-24 12:47:09 +03:00
parent 02f3a7f65c
commit e8cb6b30c9
Signed by: achuprov
GPG key ID: 2D916FFD803B0EDD

View file

@ -83,11 +83,14 @@ func transferFunds(c *helper.InitializeContext) error {
// transferFundsFinished checks balances of accounts we transfer GAS to.
// The stage is considered finished if the balance is greater than the half of what we need to transfer.
func transferFundsFinished(c *helper.InitializeContext) (bool, error) {
acc := c.Accounts[0]
r := nep17.NewReader(c.ReadOnlyInvoker, gas.Hash)
res, err := r.BalanceOf(acc.Contract.ScriptHash())
if err != nil || res.Cmp(big.NewInt(initialAlphabetGASAmount/2)) != 1 {
res, err := r.BalanceOf(c.ConsensusAcc.ScriptHash())
if err != nil {
return false, err
}
version, err := c.Client.GetVersion()
if err != nil || res.Cmp(big.NewInt(int64(version.Protocol.InitialGasDistribution))) != -1 {
return false, err
}