Skip to content

Commit

Permalink
Merge pull request #402 from iotaledger/fix/json-camel-case
Browse files Browse the repository at this point in the history
Adjusts json keys for 'PoW' and 'HRP'
  • Loading branch information
luca-moser authored Jul 26, 2022
2 parents 4b0c89d + 25b22e9 commit 1bdaf80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func (p ProtocolParameters) NetworkID() NetworkID {
type jsonProtocolParameters struct {
Version byte `json:"version"`
NetworkName string `json:"networkName"`
Bech32HRP NetworkPrefix `json:"bech32HRP"`
MinPoWScore uint32 `json:"minPoWScore"`
Bech32HRP NetworkPrefix `json:"bech32Hrp"`
MinPoWScore uint32 `json:"minPowScore"`
BelowMaxDepth uint8 `json:"belowMaxDepth"`
RentStructure RentStructure `json:"rentStructure"`
TokenSupply string `json:"tokenSupply"`
Expand Down
4 changes: 2 additions & 2 deletions protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestProtocolParametersJSONMarshalling(t *testing.T) {
},
TokenSupply: 1234567890987654321,
}
protoParasJSON := `{"version":6,"networkName":"xxxNetwork","bech32HRP":"xxx","minPoWScore":666,"belowMaxDepth":15,"rentStructure":{"vByteCost":6,"vByteFactorData":8,"vByteFactorKey":7},"tokenSupply":"1234567890987654321"}`
protoParasJSON := `{"version":6,"networkName":"xxxNetwork","bech32Hrp":"xxx","minPowScore":666,"belowMaxDepth":15,"rentStructure":{"vByteCost":6,"vByteFactorData":8,"vByteFactorKey":7},"tokenSupply":"1234567890987654321"}`

j, err := json.Marshal(protoParas)
require.NoError(t, err)
Expand All @@ -95,7 +95,7 @@ func TestProtocolParametersJSONMarshalling(t *testing.T) {
})
require.NoError(t, err)

expectedJSON := `{"protocol":{"version":6,"networkName":"xxxNetwork","bech32HRP":"xxx","minPoWScore":666,"belowMaxDepth":15,"rentStructure":{"vByteCost":6,"vByteFactorData":8,"vByteFactorKey":7},"tokenSupply":"1234567890987654321"}}`
expectedJSON := `{"protocol":{"version":6,"networkName":"xxxNetwork","bech32Hrp":"xxx","minPowScore":666,"belowMaxDepth":15,"rentStructure":{"vByteCost":6,"vByteFactorData":8,"vByteFactorKey":7},"tokenSupply":"1234567890987654321"}}`
require.Equal(t, expectedJSON, string(structBytes))

decodedStruct := &struct {
Expand Down

0 comments on commit 1bdaf80

Please sign in to comment.