Skip to content

Commit

Permalink
Merge pull request #766 from multiversx/update_enable_epochs_handler
Browse files Browse the repository at this point in the history
Update enable epochs handler
  • Loading branch information
sstanculeanu authored Sep 1, 2023
2 parents e585838 + 7dc171f commit 529cc54
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 367 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/multiversx/mx-chain-crypto-go v1.2.8
github.com/multiversx/mx-chain-logger-go v1.0.13
github.com/multiversx/mx-chain-scenario-go v1.2.1
github.com/multiversx/mx-chain-vm-common-go v1.5.6-0.20230828083058-8acb3c9d0f87
github.com/multiversx/mx-chain-vm-common-go v1.5.6-0.20230901130135-4d211b1a41d2
github.com/multiversx/mx-components-big-int v1.0.0
github.com/pelletier/go-toml v1.9.3
github.com/stretchr/testify v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ github.com/multiversx/mx-chain-logger-go v1.0.13 h1:eru/TETo0MkO4ZTnXsQDKf4PBRpA
github.com/multiversx/mx-chain-logger-go v1.0.13/go.mod h1:MZJhTAtZTJxT+yK2EHc4ZW3YOHUc1UdjCD0iahRNBZk=
github.com/multiversx/mx-chain-scenario-go v1.2.1 h1:9eC6VcOEAKRRKZ7EbSWPLzCdNIMWwuNBtAZlgR4cSMA=
github.com/multiversx/mx-chain-scenario-go v1.2.1/go.mod h1:EuZY7DpNFHVNSxJR8dKE1z2I8gBYfEFFPSwNUOXptqE=
github.com/multiversx/mx-chain-vm-common-go v1.5.6-0.20230828083058-8acb3c9d0f87 h1:66UVkqfJPw+IOtCtYfFkl5MLfopzLUCa7FpxWInHTwU=
github.com/multiversx/mx-chain-vm-common-go v1.5.6-0.20230828083058-8acb3c9d0f87/go.mod h1:uDaefuPXa9p0sb+wrUk16J0z+U324Hh894Y5oVXeVdI=
github.com/multiversx/mx-chain-vm-common-go v1.5.6-0.20230901130135-4d211b1a41d2 h1:5ZyyNUvyV4QLIjz/tHgqSDC99FmF3H2q2p3NajOTkVc=
github.com/multiversx/mx-chain-vm-common-go v1.5.6-0.20230901130135-4d211b1a41d2/go.mod h1:uDaefuPXa9p0sb+wrUk16J0z+U324Hh894Y5oVXeVdI=
github.com/multiversx/mx-components-big-int v1.0.0 h1:Wkr8lSzK2nDqixOrrBa47VNuqdhV1m/aJhaP1EMaiS8=
github.com/multiversx/mx-components-big-int v1.0.0/go.mod h1:maIEMgHlNE2u78JaDD0oLzri+ShgU4okHfzP3LWGdQM=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
4 changes: 2 additions & 2 deletions mock/context/vmHostMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type VMHostMock struct {
OutputContext vmhost.OutputContext
MeteringContext vmhost.MeteringContext
StorageContext vmhost.StorageContext
EnableEpochsHandlerField vmcommon.EnableEpochsHandler
EnableEpochsHandlerField vmhost.EnableEpochsHandler
ManagedTypesContext vmhost.ManagedTypesContext

IsBuiltinFunc bool
Expand Down Expand Up @@ -71,7 +71,7 @@ func (host *VMHostMock) Storage() vmhost.StorageContext {
}

// EnableEpochsHandler mocked method
func (host *VMHostMock) EnableEpochsHandler() vmcommon.EnableEpochsHandler {
func (host *VMHostMock) EnableEpochsHandler() vmhost.EnableEpochsHandler {
return host.EnableEpochsHandlerField
}

Expand Down
4 changes: 2 additions & 2 deletions mock/context/vmHostStub.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type VMHostStub struct {
MeteringCalled func() vmhost.MeteringContext
AsyncCalled func() vmhost.AsyncContext
StorageCalled func() vmhost.StorageContext
EnableEpochsHandlerCalled func() vmcommon.EnableEpochsHandler
EnableEpochsHandlerCalled func() vmhost.EnableEpochsHandler
GetContextsCalled func() (vmhost.ManagedTypesContext, vmhost.BlockchainContext, vmhost.MeteringContext, vmhost.OutputContext, vmhost.RuntimeContext, vmhost.AsyncContext, vmhost.StorageContext)
ManagedTypesCalled func() vmhost.ManagedTypesContext

Expand Down Expand Up @@ -160,7 +160,7 @@ func (vhs *VMHostStub) Storage() vmhost.StorageContext {
}

// EnableEpochsHandler mocked method
func (vhs *VMHostStub) EnableEpochsHandler() vmcommon.EnableEpochsHandler {
func (vhs *VMHostStub) EnableEpochsHandler() vmhost.EnableEpochsHandler {
if vhs.EnableEpochsHandlerCalled != nil {
return vhs.EnableEpochsHandlerCalled()
}
Expand Down
33 changes: 26 additions & 7 deletions mock/world/builtinFunctionsWrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package worldmock
import (
"bytes"

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/marshal"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
"github.com/multiversx/mx-chain-vm-common-go/builtInFunctions"
"github.com/multiversx/mx-chain-vm-common-go/mock"
"github.com/multiversx/mx-chain-vm-go/config"
)

Expand All @@ -33,13 +35,30 @@ func NewBuiltinFunctionsWrapper(
dnsMap := makeDNSAddresses(numDNSAddresses)

argsBuiltIn := builtInFunctions.ArgsCreateBuiltInFunctionContainer{
GasMap: gasMap,
MapDNSAddresses: dnsMap,
MapDNSV2Addresses: dnsMap,
Marshalizer: WorldMarshalizer,
Accounts: world.AccountsAdapter,
ShardCoordinator: world,
EnableEpochsHandler: EnableEpochsHandlerStubAllFlags(),
GasMap: gasMap,
MapDNSAddresses: dnsMap,
MapDNSV2Addresses: dnsMap,
Marshalizer: WorldMarshalizer,
Accounts: world.AccountsAdapter,
ShardCoordinator: world,
EnableEpochsHandler: &mock.EnableEpochsHandlerStub{
IsFlagEnabledCalled: func(flag core.EnableEpochFlag) bool {
return flag == builtInFunctions.CheckCorrectTokenIDForTransferRoleFlag ||
flag == builtInFunctions.ESDTTransferRoleFlag ||
flag == builtInFunctions.GlobalMintBurnFlag ||
flag == builtInFunctions.TransferToMetaFlag ||
flag == builtInFunctions.CheckFrozenCollectionFlag ||
flag == builtInFunctions.FixAsyncCallbackCheckFlag ||
flag == builtInFunctions.ESDTNFTImprovementV1Flag ||
flag == builtInFunctions.SaveToSystemAccountFlag ||
flag == builtInFunctions.ValueLengthCheckFlag ||
flag == builtInFunctions.CheckFunctionArgumentFlag ||
flag == builtInFunctions.FixOldTokenLiquidityFlag ||
flag == builtInFunctions.AlwaysSaveTokenMetaDataFlag ||
flag == builtInFunctions.SetGuardianFlag ||
flag == builtInFunctions.ScToScLogEventFlag
},
},
GuardedAccountHandler: world.GuardedAccountHandler,
MaxNumOfAddressesForTransferRole: 100,
}
Expand Down
Loading

0 comments on commit 529cc54

Please sign in to comment.