Skip to content
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

update go mod and refactor some tests #6458

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:

- name: Upload test report
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pytest-report-${{ github.run_id }}
path: reports/report.html
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ require (
github.com/multiversx/mx-chain-communication-go v1.1.0
github.com/multiversx/mx-chain-core-go v1.2.22
github.com/multiversx/mx-chain-crypto-go v1.2.12
github.com/multiversx/mx-chain-es-indexer-go v1.7.8
github.com/multiversx/mx-chain-es-indexer-go v1.7.9-0.20240912110120-3287bbe713da
github.com/multiversx/mx-chain-logger-go v1.0.15
github.com/multiversx/mx-chain-scenario-go v1.4.4
github.com/multiversx/mx-chain-storage-go v1.0.16
github.com/multiversx/mx-chain-vm-common-go v1.5.14
github.com/multiversx/mx-chain-vm-go v1.5.32
github.com/multiversx/mx-chain-vm-common-go v1.5.15-0.20240912084229-e96c462e523d
github.com/multiversx/mx-chain-vm-go v1.5.33-0.20240912115217-e4a93d0c7fa2
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.98
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,18 @@ github.com/multiversx/mx-chain-core-go v1.2.22 h1:yDYrvoQOBbsDerEp7L3+de5AfMy3pT
github.com/multiversx/mx-chain-core-go v1.2.22/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk=
github.com/multiversx/mx-chain-crypto-go v1.2.12/go.mod h1:HzcPpCm1zanNct/6h2rIh+MFrlXbjA5C8+uMyXj3LI4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.8 h1:ZDKTXkQhQ7lLi6huVrBTUssVEqCvaCxGH4Y52GapboQ=
github.com/multiversx/mx-chain-es-indexer-go v1.7.8/go.mod h1:oGcRK2E3Syv6vRTszWrrb/TqD8akq0yeoMr1wPPiTO4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.9-0.20240912110120-3287bbe713da h1:Dk0UXrr4rwMblSnsXWERKiqi1Jwa+bWIrLn7J03ixZU=
github.com/multiversx/mx-chain-es-indexer-go v1.7.9-0.20240912110120-3287bbe713da/go.mod h1:oGcRK2E3Syv6vRTszWrrb/TqD8akq0yeoMr1wPPiTO4=
github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc=
github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ=
github.com/multiversx/mx-chain-scenario-go v1.4.4 h1:DVE2V+FPeyD/yWoC+KEfPK3jsFzHeruelESfpTlf460=
github.com/multiversx/mx-chain-scenario-go v1.4.4/go.mod h1:kI+TWR3oIEgUkbwkHCPo2CQ3VjIge+ezGTibiSGwMxo=
github.com/multiversx/mx-chain-storage-go v1.0.16 h1:l2lJq+EAN3YwLbjJrnoKfFd1/1Xmo9DcAUECND2obLs=
github.com/multiversx/mx-chain-storage-go v1.0.16/go.mod h1:uM/z7YyqTOD3wgyH8TfapyEl5sb+7x/Jaxne4cfG4HI=
github.com/multiversx/mx-chain-vm-common-go v1.5.14 h1:QauClmsZVKnShhvAVkXndO4j25q361SPvt9dqdx1qlM=
github.com/multiversx/mx-chain-vm-common-go v1.5.14/go.mod h1:1rSkXreUZNXyPTTdhj47M+Fy62yjxbu3aAsXEtKN3UY=
github.com/multiversx/mx-chain-vm-go v1.5.32 h1:bEHKmXhjo2aHsx+cFDtKRV7/uq0yBip47gj9Xrl/B84=
github.com/multiversx/mx-chain-vm-go v1.5.32/go.mod h1:yjOCetRG0wFXm+IWGyioipdR959TYoR+FRdAGVq8xXw=
github.com/multiversx/mx-chain-vm-common-go v1.5.15-0.20240912084229-e96c462e523d h1:R/4JLgd6voLZPieHhHCh3uTztlSym0iDI8fkMpN4JAE=
github.com/multiversx/mx-chain-vm-common-go v1.5.15-0.20240912084229-e96c462e523d/go.mod h1:1rSkXreUZNXyPTTdhj47M+Fy62yjxbu3aAsXEtKN3UY=
github.com/multiversx/mx-chain-vm-go v1.5.33-0.20240912115217-e4a93d0c7fa2 h1:p8pHfq+VhdKUp4oSP0QEjUkjAVLpXlCXnM4eS1vsGoo=
github.com/multiversx/mx-chain-vm-go v1.5.33-0.20240912115217-e4a93d0c7fa2/go.mod h1:3LmdbQOb+Fy3UqF9DtQ9j/RITetee9CHbEm+PV+JrC4=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68 h1:L3GoAVFtLLzr9ya0rVv1YdTUzS3MyM7kQNBSAjCNO2g=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68/go.mod h1:ixxwib+1pXwSDHG5Wa34v0SRScF+BwFzH4wFWY31saI=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69 h1:G/PLsyfQV4bMLs2amGRvaLKZoW1DC7M+7ecVaLuaCNc=
Expand Down
73 changes: 72 additions & 1 deletion integrationTests/chainSimulator/vm/esdtImprovements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,18 @@ func checkMetaData(
require.Equal(t, expectedMetaData.Attributes, []byte(hex.EncodeToString(retrievedMetaData.Attributes)))
}

func checkReservedField(
t *testing.T,
cs testsChainSimulator.ChainSimulator,
addressBytes []byte,
tokenID []byte,
shardID uint32,
expectedReservedField []byte,
) {
esdtData := getESDTDataFromAcc(t, cs, addressBytes, tokenID, shardID)
require.Equal(t, expectedReservedField, esdtData.Reserved)
}

func checkMetaDataNotInAcc(
t *testing.T,
cs testsChainSimulator.ChainSimulator,
Expand Down Expand Up @@ -3861,7 +3873,7 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
baseIssuingCost := "1000"
cs, _ := getTestChainSimulatorWithDynamicNFTEnabled(t, baseIssuingCost)
defer cs.Close()

marshaller := cs.GetNodeHandler(0).GetCoreComponents().InternalMarshalizer()
addrs := createAddresses(t, cs, true)

log.Info("Register dynamic metaESDT token")
Expand Down Expand Up @@ -3930,6 +3942,7 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
shardID := cs.GetNodeHandler(0).GetProcessComponents().ShardCoordinator().ComputeId(addrs[0].Bytes)

checkMetaData(t, cs, core.SystemAccountAddress, tokenID, shardID, metaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, shardID, []byte{1})

log.Info("send metaEsdt cross shard")

Expand Down Expand Up @@ -3964,8 +3977,19 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
expectedMetaData.Hash = newMetaData.Hash
expectedMetaData.Attributes = newMetaData.Attributes

round := cs.GetNodeHandler(0).GetChainHandler().GetCurrentBlockHeader().GetRound()
reserved := &esdt.MetaDataVersion{
Name: round,
Creator: round,
Hash: round,
Attributes: round,
}
firstVersion, _ := marshaller.Marshal(reserved)

checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 0, expectedMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 0, firstVersion)
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 1, metaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 1, []byte{1})

log.Info("send the update role to shard 2")

Expand All @@ -3988,7 +4012,9 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
require.Equal(t, "success", txResult.Status.String())

checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 0, expectedMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 0, firstVersion)
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 1, metaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 1, []byte{1})

retrievedMetaData := getMetaDataFromAcc(t, cs, core.SystemAccountAddress, tokenID, 2)
require.Equal(t, uint64(0), retrievedMetaData.Nonce)
Expand All @@ -4002,6 +4028,15 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
}
require.Equal(t, 0, len(retrievedMetaData.Attributes))

round2 := cs.GetNodeHandler(2).GetChainHandler().GetCurrentBlockHeader().GetRound()
reserved = &esdt.MetaDataVersion{
URIs: round2,
Creator: round2,
Royalties: round2,
}
secondVersion, _ := cs.GetNodeHandler(shardID).GetCoreComponents().InternalMarshalizer().Marshal(reserved)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 2, secondVersion)

log.Info("transfer from shard 0 to shard 1 - should merge metaData")

tx = esdtNFTTransferTx(shard0Nonce, addrs[0].Bytes, addrs[1].Bytes, tokenID)
Expand All @@ -4015,7 +4050,9 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
require.Nil(t, err)

checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 0, expectedMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 0, firstVersion)
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 1, expectedMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 1, firstVersion)

log.Info("transfer from shard 1 to shard 2 - should merge metaData")

Expand All @@ -4036,7 +4073,9 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
require.Nil(t, err)

checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 0, expectedMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 0, firstVersion)
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 1, expectedMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 1, firstVersion)

latestMetaData := txsFee.GetDefaultMetaData()
latestMetaData.Nonce = expectedMetaData.Nonce
Expand All @@ -4047,6 +4086,17 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
latestMetaData.Uris = newMetaData2.Uris
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 2, latestMetaData)

reserved = &esdt.MetaDataVersion{
Name: round,
Creator: round2,
Royalties: round2,
Hash: round,
URIs: round2,
Attributes: round,
}
thirdVersion, _ := cs.GetNodeHandler(shardID).GetCoreComponents().InternalMarshalizer().Marshal(reserved)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 2, thirdVersion)

log.Info("transfer from shard 2 to shard 0 - should update metaData")

tx = setSpecialRoleTx(shard0Nonce, addrs[0].Bytes, addrs[2].Bytes, tokenID, [][]byte{[]byte(core.ESDTRoleTransfer)})
Expand All @@ -4065,8 +4115,29 @@ func TestChainSimulator_metaESDT_mergeMetaDataFromMultipleUpdates(t *testing.T)
require.Nil(t, err)

checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 0, latestMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 0, thirdVersion)
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 1, expectedMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 1, firstVersion)
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 2, latestMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 2, thirdVersion)

log.Info("transfer from shard 1 to shard 0 - liquidity should be updated")

tx = esdtNFTTransferTx(1, addrs[1].Bytes, addrs[0].Bytes, tokenID)
txResult, err = cs.SendTxAndGenerateBlockTilTxIsExecuted(tx, maxNumOfBlockToGenerateWhenExecutingTx)
require.Nil(t, err)
require.NotNil(t, txResult)
require.Equal(t, "success", txResult.Status.String())

err = cs.GenerateBlocks(10)
require.Nil(t, err)

checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 0, latestMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 0, thirdVersion)
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 1, expectedMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 1, firstVersion)
checkMetaData(t, cs, core.SystemAccountAddress, tokenID, 2, latestMetaData)
checkReservedField(t, cs, core.SystemAccountAddress, tokenID, 2, thirdVersion)
}

func unsetSpecialRole(
Expand Down
Loading