Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed May 7, 2024
1 parent e696a8e commit af808a6
Show file tree
Hide file tree
Showing 18 changed files with 291 additions and 267 deletions.
4 changes: 2 additions & 2 deletions lib/go/contracts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.18
require (
github.com/kevinburke/go-bindata v3.24.0+incompatible
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240215153337-0be5cb4b4bc9
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424211859-3ff4c0fe2a1e
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240429184308-40c3de711140
github.com/onflow/flow-ft/lib/go/contracts v1.0.0
github.com/onflow/flow-nft/lib/go/contracts v1.2.0
github.com/stretchr/testify v1.8.4
)

Expand Down
12 changes: 4 additions & 8 deletions lib/go/contracts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1617,18 +1617,14 @@ github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240215153337-0be5cb4b4bc9 h1:rTemckPWir+N/m1GyhT8jdiETj0RiWc8FiwItE2Nxyg=
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240215153337-0be5cb4b4bc9/go.mod h1:PZrrCsllIt/Bu4HlJtisXfvDrOt1aLKU5R70vsZHKRc=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424142855-b518689a350b h1:HutxHvyc06UbJncEUieAwt7Nf1lG5uiIGVok6w031LM=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424142855-b518689a350b/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424211859-3ff4c0fe2a1e h1:2LO6Rtmz2PVfH+ZXnMwvTwVeIz3PCy0fs3lQraqog14=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424211859-3ff4c0fe2a1e/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/Sy/tIXdw90yKHcV0=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240213220156-959b70719876 h1:fZj39XxayIL7uvKvonNI3MtQM3wsFJ8oRl/XW/0rn7A=
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240213220156-959b70719876/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
github.com/onflow/flow-go-sdk v1.0.0-M1 h1:mke/ebYwNRRWPZqcwCV56Alx0A8psew43ZbSEUQ4TL8=
github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo=
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240424144730-4a6f42d2a372 h1:jVrUFQ5Fn3gBKZ3Q6OVhceF2vKiHg1la6g3DuRKvdoo=
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240424144730-4a6f42d2a372/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240429184308-40c3de711140 h1:oTj4RGgfuJSSBE1aDVrlh6avxKBMraucpNtRg0K+yhg=
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240429184308-40c3de711140/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
github.com/onflow/flow-nft/lib/go/contracts v1.2.0 h1:TFH7GCJKcGi0+x14SCvF7Gbnxp68gJOGNV8PSIAM2J0=
github.com/onflow/flow-nft/lib/go/contracts v1.2.0/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240213205729-48f42d9896f8 h1:BqgQgXktxVFv8erjCaSHpL0CP+pa5M8g655GyF/t4JM=
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240213205729-48f42d9896f8/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2 h1:qZjl4wSTG/E9znEjkHF0nNaEdlBLJoOEAtr7xUsTNqc=
Expand Down
9 changes: 1 addition & 8 deletions lib/go/templates/delegator_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
)

const (
createDelegationFilename = "idTableStaking/delegation/del_create_delegation.cdc"
delegatorAddCapabilityFilename = "idTableStaking/delegation/delegator_add_capability.cdc"
createDelegationFilename = "idTableStaking/delegation/del_create_delegation.cdc"

delegatorRegisterFilename = "idTableStaking/delegation/register_delegator.cdc"
delegatorStakeNewFilename = "idTableStaking/delegation/del_stake_new_tokens.cdc"
Expand Down Expand Up @@ -77,12 +76,6 @@ func GenerateDelegatorWithdrawRewardsScript(env Environment) []byte {
return []byte(ReplaceAddresses(code, env))
}

func GenerateAddPublicDelegatorCapabilityScript(env Environment) []byte {
code := assets.MustAssetString(delegatorAddCapabilityFilename)

return []byte(ReplaceAddresses(code, env))
}

// Scripts

func GenerateGetDelegatorInfoScript(env Environment) []byte {
Expand Down
4 changes: 2 additions & 2 deletions lib/go/templates/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.18
require (
github.com/kevinburke/go-bindata v3.24.0+incompatible
github.com/onflow/cadence v1.0.0-M3
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424211859-3ff4c0fe2a1e
github.com/onflow/flow-ft/lib/go/templates v1.0.0
github.com/onflow/flow-go-sdk v1.0.0-M1
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240429184308-40c3de711140
github.com/onflow/flow-nft/lib/go/templates v1.2.0
github.com/psiemens/sconfig v0.1.0
github.com/spf13/cobra v1.5.0
)
Expand Down
12 changes: 4 additions & 8 deletions lib/go/templates/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1615,16 +1615,12 @@ github.com/onflow/cadence v1.0.0-M3 h1:bSydJise9pU4aALloUKv/EWmDLITRlbBpuG8OPByd
github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8=
github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424142855-b518689a350b h1:Z/Fn+7ysdfuv8yKzhPlZ+HrADm3zaUi+zb6BP4JWLfU=
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424142855-b518689a350b/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424211859-3ff4c0fe2a1e h1:jl7SYAui/gYRmBofrY//Ln8ixRJwvLzvwLstNfRKmWY=
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424211859-3ff4c0fe2a1e/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs=
github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
github.com/onflow/flow-go-sdk v1.0.0-M1 h1:mke/ebYwNRRWPZqcwCV56Alx0A8psew43ZbSEUQ4TL8=
github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo=
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240424144730-4a6f42d2a372 h1:zjEANfSuCctAQ79IotaP6+v0jZiJsDAlikcZC++BTpc=
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240424144730-4a6f42d2a372/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240429184308-40c3de711140 h1:7NwSIG4SEdm+96gr+Aaqx291jZ/Bqkxk/ghVnens9CU=
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240429184308-40c3de711140/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc=
github.com/onflow/flow-nft/lib/go/templates v1.2.0/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2 h1:qZjl4wSTG/E9znEjkHF0nNaEdlBLJoOEAtr7xUsTNqc=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU=
Expand Down
7 changes: 0 additions & 7 deletions lib/go/templates/idtable_staking_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const (
withdrawUnstakedTokensFilename = "idTableStaking/node/withdraw_unstaked_tokens.cdc"
withdrawRewardedTokensFilename = "idTableStaking/node/withdraw_rewarded_tokens.cdc"
updateNetworkingAddressFilename = "idTableStaking/node/update_networking_address.cdc"
addPublicNodeCapabilityFilename = "idTableStaking/node/node_add_capability.cdc"

registerManyNodesFilename = "idTableStaking/node/register_many_nodes.cdc"

Expand Down Expand Up @@ -343,12 +342,6 @@ func GenerateUpdateNetworkingAddressScript(env Environment) []byte {
return []byte(ReplaceAddresses(code, env))
}

func GenerateAddPublicNodeCapabilityScript(env Environment) []byte {
code := assets.MustAssetString(addPublicNodeCapabilityFilename)

return []byte(ReplaceAddresses(code, env))
}

// GenerateReturnTableScript creates a script that returns
// the the whole ID table nodeIDs
func GenerateReturnTableScript(env Environment) []byte {
Expand Down
106 changes: 54 additions & 52 deletions lib/go/test/epoch_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,31 @@ type EpochStart struct {
type EpochStartEvent flow.Event

func (evt EpochStartEvent) Counter() cadence.UInt64 {
return evt.Value.Fields[0].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "counter").(cadence.UInt64)
}

func (evt EpochStartEvent) firstView() cadence.UInt64 {
return evt.Value.Fields[1].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "firstView").(cadence.UInt64)
}

func (evt EpochStartEvent) stakingEndView() cadence.UInt64 {
return evt.Value.Fields[2].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "stakingAuctionEndView").(cadence.UInt64)
}

func (evt EpochStartEvent) finalView() cadence.UInt64 {
return evt.Value.Fields[3].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "finalView").(cadence.UInt64)
}

func (evt EpochStartEvent) totalStaked() cadence.UFix64 {
return evt.Value.Fields[4].(cadence.UFix64)
return cadence.SearchFieldByName(evt.Value, "totalStaked").(cadence.UFix64)
}

func (evt EpochStartEvent) totalSupply() cadence.UFix64 {
return evt.Value.Fields[5].(cadence.UFix64)
return cadence.SearchFieldByName(evt.Value, "totalFlowSupply").(cadence.UFix64)
}

func (evt EpochStartEvent) rewards() cadence.UFix64 {
return evt.Value.Fields[6].(cadence.UFix64)
return cadence.SearchFieldByName(evt.Value, "totalRewards").(cadence.UFix64)
}

// / Used to verify the EpochSetup event fields in tests
Expand Down Expand Up @@ -136,54 +136,54 @@ type EpochCommit struct {
type EpochSetupEvent flow.Event

func (evt EpochSetupEvent) Counter() cadence.UInt64 {
return evt.Value.Fields[0].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "counter").(cadence.UInt64)
}

func (evt EpochSetupEvent) NodeInfo() cadence.Array {
return evt.Value.Fields[1].(cadence.Array)
return cadence.SearchFieldByName(evt.Value, "nodeInfo").(cadence.Array)
}

func (evt EpochSetupEvent) firstView() cadence.UInt64 {
return evt.Value.Fields[2].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "firstView").(cadence.UInt64)
}

func (evt EpochSetupEvent) finalView() cadence.UInt64 {
return evt.Value.Fields[3].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "finalView").(cadence.UInt64)
}

func (evt EpochSetupEvent) collectorClusters() cadence.Array {
return evt.Value.Fields[4].(cadence.Array)
return cadence.SearchFieldByName(evt.Value, "collectorClusters").(cadence.Array)
}

func (evt EpochSetupEvent) randomSource() cadence.String {
return evt.Value.Fields[5].(cadence.String)
return cadence.SearchFieldByName(evt.Value, "randomSource").(cadence.String)
}

func (evt EpochSetupEvent) dkgFinalViews() (cadence.UInt64, cadence.UInt64, cadence.UInt64) {
fields := evt.Value.Fields
return fields[6].(cadence.UInt64), fields[7].(cadence.UInt64), fields[8].(cadence.UInt64)
fields := cadence.FieldsMappedByName(evt.Value)
return fields["DKGPhase1FinalView"].(cadence.UInt64), fields["DKGPhase2FinalView"].(cadence.UInt64), fields["DKGPhase3FinalView"].(cadence.UInt64)
}

func (evt EpochSetupEvent) targetDuration() cadence.UInt64 {
return evt.Value.Fields[9].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "targetDuration").(cadence.UInt64)
}

func (evt EpochSetupEvent) targetEndTime() cadence.UInt64 {
return evt.Value.Fields[10].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "targetEndTime").(cadence.UInt64)
}

type EpochCommitEvent flow.Event

func (evt EpochCommitEvent) Counter() cadence.UInt64 {
return evt.Value.Fields[0].(cadence.UInt64)
return cadence.SearchFieldByName(evt.Value, "counter").(cadence.UInt64)
}

func (evt EpochCommitEvent) clusterQCs() cadence.Array {
return evt.Value.Fields[1].(cadence.Array)
return cadence.SearchFieldByName(evt.Value, "clusterQCs").(cadence.Array)
}

func (evt EpochCommitEvent) dkgPubKeys() cadence.Array {
return evt.Value.Fields[2].(cadence.Array)
return cadence.SearchFieldByName(evt.Value, "dkgPubKeys").(cadence.Array)
}

// / Deploys the Quroum Certificate and Distributed Key Generation contracts to the provided account
Expand Down Expand Up @@ -427,13 +427,14 @@ func verifyClusters(
found := false

for _, actualCluster := range actualClusters {
cluster := actualCluster.(cadence.Struct).Fields
cluster := actualCluster.(cadence.Struct)
clusterFields := cadence.FieldsMappedByName(cluster)

totalWeight := cluster[2]
totalWeight := clusterFields["totalWeight"]
if cadence.NewUInt64(expectedCluster.totalWeight) == totalWeight {
found = true
assertEqual(t, cadence.NewUInt64(expectedCluster.totalWeight), totalWeight)
size := len(cluster[1].(cadence.Dictionary).Pairs)
size := len(clusterFields["nodeWeights"].(cadence.Dictionary).Pairs)
assertEqual(t, cadence.NewUInt16(expectedCluster.size), cadence.NewUInt16(uint16(size)))
}
}
Expand All @@ -458,9 +459,10 @@ func verifyClusterQCs(
i := 0
for _, qc := range actualQCs {
found := false
qcStructSignatures := qc.(cadence.Struct).Fields[1].(cadence.Array).Values
qcStructMessage := qc.(cadence.Struct).Fields[2].(cadence.String)
qcVoterIDs := qc.(cadence.Struct).Fields[3].(cadence.Array).Values
qcStructFields := cadence.FieldsMappedByName(qc.(cadence.Struct))
qcStructSignatures := qcStructFields["voteSignatures"].(cadence.Array).Values
qcStructMessage := qcStructFields["voteMessage"].(cadence.String)
qcVoterIDs := qcStructFields["voterIDs"].(cadence.Array).Values

assertEqual(t, len(qcVoterIDs), len(qcStructSignatures))

Expand Down Expand Up @@ -494,47 +496,47 @@ func verifyEpochMetadata(
expectedMetadata EpochMetadata) {

result := executeScriptAndCheck(t, b, templates.GenerateGetEpochMetadataScript(env), [][]byte{jsoncdc.MustEncode(cadence.UInt64(expectedMetadata.counter))})
metadataFields := result.(cadence.Struct).Fields
metadataFields := cadence.FieldsMappedByName(result.(cadence.Struct))

counter := metadataFields[0]
counter := metadataFields["counter"]
assertEqual(t, cadence.NewUInt64(expectedMetadata.counter), counter)

if len(expectedMetadata.seed) != 0 {
seed := metadataFields[1]
seed := metadataFields["seed"]
cadenceSeed, _ := cadence.NewString(expectedMetadata.seed)
assertEqual(t, cadenceSeed, seed)
}

startView := metadataFields[2]
startView := metadataFields["startView"]
assertEqual(t, cadence.NewUInt64(expectedMetadata.startView), startView)

endView := metadataFields[3]
endView := metadataFields["endView"]
assertEqual(t, cadence.NewUInt64(expectedMetadata.endView), endView)

stakingEndView := metadataFields[4]
stakingEndView := metadataFields["stakingEndView"]
assertEqual(t, cadence.NewUInt64(expectedMetadata.stakingEndView), stakingEndView)

totalRewards := metadataFields[5]
totalRewards := metadataFields["totalRewards"]
assertEqual(t, CadenceUFix64(expectedMetadata.totalRewards), totalRewards)

rewardsArray := metadataFields[6].(cadence.Array).Values
rewardsArray := metadataFields["rewardAmounts"].(cadence.Array).Values
if expectedMetadata.rewardsBreakdownArray == 0 {
assertEqual(t, len(rewardsArray), 0)
}

rewardsPaid := metadataFields[7]
rewardsPaid := metadataFields["rewardsPaid"]
assertEqual(t, cadence.NewBool(expectedMetadata.rewardsPaid), rewardsPaid)

if expectedMetadata.collectorClusters != nil {
clusters := metadataFields[8].(cadence.Array).Values
clusters := metadataFields["collectorClusters"].(cadence.Array).Values

verifyClusters(t, expectedMetadata.collectorClusters, clusters)
}

clusterQCs := metadataFields[9].(cadence.Array).Values
clusterQCs := metadataFields["clusterQCs"].(cadence.Array).Values
verifyClusterQCs(t, expectedMetadata.clusterQCs, clusterQCs)

dkgKeys := metadataFields[10].(cadence.Array).Values
dkgKeys := metadataFields["dkgKeys"].(cadence.Array).Values
if expectedMetadata.dkgKeys == nil {
assert.Empty(t, dkgKeys)
} else {
Expand All @@ -558,12 +560,12 @@ func verifyEpochTimingConfig(
) {

result := executeScriptAndCheck(t, b, templates.GenerateGetEpochTimingConfigScript(env), nil)
timingConfigFields := result.(cadence.Struct).Fields
timingConfigFields := cadence.FieldsMappedByName(result.(cadence.Struct))

// A default epoch timing config should be set in the constructor
assertEqual(t, cadence.NewUInt64(expectedConfig.duration), timingConfigFields[0])
assertEqual(t, cadence.NewUInt64(expectedConfig.refCounter), timingConfigFields[1])
assert.InDelta(t, expectedConfig.refTimestamp, timingConfigFields[2].ToGoValue().(uint64), 30)
assertEqual(t, cadence.NewUInt64(expectedConfig.duration), timingConfigFields["duration"])
assertEqual(t, cadence.NewUInt64(expectedConfig.refCounter), timingConfigFields["refCounter"])
assert.InDelta(t, expectedConfig.refTimestamp, uint64(timingConfigFields["refTimestamp"].(cadence.UInt64)), 30)
}

// / Verifies that the configurable epoch metadata is equal to the provided values
Expand All @@ -580,16 +582,16 @@ func verifyConfigMetadata(
assertEqual(t, cadence.NewUInt64(expectedMetadata.proposedEpochCounter), result)

result = executeScriptAndCheck(t, b, templates.GenerateGetEpochConfigMetadataScript(env), nil)
metadataFields := result.(cadence.Struct).Fields
metadataFields := cadence.FieldsMappedByName(result.(cadence.Struct))

assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInEpoch), metadataFields[0])
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInStakingAuction), metadataFields[1])
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInDKGPhase), metadataFields[2])
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInEpoch), metadataFields["numViewsInEpoch"])
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInStakingAuction), metadataFields["numViewsInStakingAuction"])
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInDKGPhase), metadataFields["numViewsInDKGPhase"])

clusters := metadataFields[3]
clusters := metadataFields["numCollectorClusters"]
assertEqual(t, cadence.NewUInt16(expectedMetadata.numCollectorClusters), clusters)

apy := metadataFields[4]
apy := metadataFields["FLOWsupplyIncreasePercentage"]
assertEqual(t, CadenceUFix64(expectedMetadata.rewardPercentage), apy)

result = executeScriptAndCheck(t, b, templates.GenerateGetEpochPhaseScript(env), nil)
Expand Down Expand Up @@ -715,10 +717,10 @@ func verifyEpochCommit(
// expectedTargetEndTime returns the expected `targetEndTime` for the given target epoch,
// as a second-precision Unix time.
func expectedTargetEndTime(timingConfig cadence.Value, targetEpoch uint64) uint64 {
fields := timingConfig.(cadence.Struct).Fields
duration := fields[0].ToGoValue().(uint64)
refCounter := fields[1].ToGoValue().(uint64)
refTimestamp := fields[2].ToGoValue().(uint64)
fields := cadence.FieldsMappedByName(timingConfig.(cadence.Struct))
duration := uint64(fields["duration"].(cadence.UInt64))
refCounter := uint64(fields["refCounter"].(cadence.UInt64))
refTimestamp := uint64(fields["refTimestamp"].(cadence.UInt64))

return refTimestamp + duration*(targetEpoch-refCounter)
}
Loading

0 comments on commit af808a6

Please sign in to comment.