-
Notifications
You must be signed in to change notification settings - Fork 95
/
api_test.go
133 lines (123 loc) · 2.88 KB
/
api_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package iotago_test
import (
"testing"
iotago "github.com/iotaledger/iota.go/v4"
"github.com/iotaledger/iota.go/v4/tpkg"
"github.com/iotaledger/iota.go/v4/tpkg/frameworks"
)
const (
OneIOTA iotago.BaseToken = 1_000_000
)
func TestProtocolParameters_DeSerialize(t *testing.T) {
tests := []*frameworks.DeSerializeTest{
{
Name: "ok",
Source: tpkg.RandProtocolParameters(),
Target: &iotago.V3ProtocolParameters{},
SeriErr: nil,
DeSeriErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.Name, tt.Run)
}
}
func TestProtocolParametersJSONMarshalling(t *testing.T) {
protoParams := iotago.NewV3SnapshotProtocolParameters(
iotago.WithTimeProviderOptions(1, 1690879505, 10, 13),
)
// replace the decay factors to reduce the size of the JSON string
protoParams.ManaParameters().DecayFactors = []uint32{
1,
2,
3,
}
tests := []*frameworks.JSONEncodeTest{
{
Name: "ok",
Source: protoParams,
Target: `{
"type": 0,
"version": 3,
"networkName": "testnet",
"bech32Hrp": "rms",
"storageScoreParameters": {
"storageCost": "100",
"factorData": 1,
"offsetOutputOverhead": "10",
"offsetEd25519BlockIssuerKey": "100",
"offsetStakingFeature": "100",
"offsetDelegation": "100"
},
"workScoreParameters": {
"dataByte": 500,
"block": 110000,
"input": 7500,
"contextInput": 40000,
"output": 90000,
"nativeToken": 50000,
"staking": 40000,
"blockIssuer": 70000,
"allotment": 5000,
"signatureEd25519": 15000
},
"manaParameters": {
"bitsCount": 63,
"generationRate": 1,
"generationRateExponent": 17,
"decayFactors": [
1,
2,
3
],
"decayFactorsExponent": 32,
"decayFactorEpochsSum": 2262417561,
"decayFactorEpochsSumExponent": 21,
"annualDecayFactorPercentage": 70
},
"tokenSupply": "1813620509061365",
"genesisSlot": 1,
"genesisUnixTimestamp": "1690879505",
"slotDurationInSeconds": 10,
"slotsPerEpochExponent": 13,
"stakingUnbondingPeriod": 10,
"validationBlocksPerSlot": 10,
"punishmentEpochs": 10,
"livenessThresholdLowerBound": 15,
"livenessThresholdUpperBound": 30,
"minCommittableAge": 10,
"maxCommittableAge": 20,
"epochNearingThreshold": 60,
"congestionControlParameters": {
"minReferenceManaCost": "1",
"increase": "1",
"decrease": "1",
"increaseThreshold": 400000000,
"decreaseThreshold": 250000000,
"schedulerRate": 50000000,
"maxBufferSize": 1000,
"maxValidationBufferSize": 100
},
"versionSignalingParameters": {
"windowSize": 7,
"windowTargetRatio": 5,
"activationOffset": 7
},
"rewardsParameters": {
"profitMarginExponent": 8,
"bootstrappingDuration": 1079,
"rewardToGenerationRatio": 2,
"initialTargetRewardsRate": "616067521149261",
"finalTargetRewardsRate": "226702563632670",
"poolCoefficientExponent": 11,
"retentionPeriod": 384
},
"targetCommitteeSize": 32,
"chainSwitchingThreshold": 3
}`,
},
}
for _, tt := range tests {
t.Run(tt.Name, tt.Run)
}
}