-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cluster/state: legacy lock json and transform (#2182)
Add legacy lock serialisation and transform logic. category: feature ticket: #1886
- Loading branch information
1 parent
57408a7
commit 0ee68ed
Showing
10 changed files
with
508 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright © 2022-2023 Obol Labs Inc. Licensed under the terms of a Business Source License 1.1 | ||
|
||
package state_test | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/obolnetwork/charon/cluster" | ||
"github.com/obolnetwork/charon/cluster/state" | ||
"github.com/obolnetwork/charon/testutil" | ||
) | ||
|
||
//go:generate go test . -update | ||
|
||
func TestLegacyLock(t *testing.T) { | ||
lockJON, err := os.ReadFile("testdata/lock.json") | ||
require.NoError(t, err) | ||
|
||
var lock cluster.Lock | ||
testutil.RequireNoError(t, json.Unmarshal(lockJON, &lock)) | ||
|
||
signed, err := state.NewLegacyLock(lock) | ||
require.NoError(t, err) | ||
|
||
t.Run("json", func(t *testing.T) { | ||
testutil.RequireGoldenJSON(t, signed) | ||
}) | ||
|
||
t.Run("cluster", func(t *testing.T) { | ||
cluster, err := signed.Mutation.Type.Transform(state.Cluster{}, signed) | ||
require.NoError(t, err) | ||
testutil.RequireGoldenJSON(t, cluster) | ||
}) | ||
|
||
b, err := json.MarshalIndent(signed, "", " ") | ||
require.NoError(t, err) | ||
|
||
var signed2 state.SignedMutation | ||
testutil.RequireNoError(t, json.Unmarshal(b, &signed2)) | ||
|
||
t.Run("json again", func(t *testing.T) { | ||
testutil.RequireGoldenJSON(t, signed2, testutil.WithFilename("TestLegacyLock_json.golden")) | ||
}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"Name": "test cluster", | ||
"Threshold": 3, | ||
"DKGAlgorithm": "default", | ||
"ForkVersion": "AAAQIA==", | ||
"Operators": [ | ||
{ | ||
"Address": "0x5050A4F4b3f9338C3472dcC01A87C76A144b3c9c", | ||
"ENR": "enr:-HW4QIHPUOMb34YoizKGhz7nsDNQ7hCaiuwyscmeaOQ04awdH05gDnGrZhxDfzcfHssCDeB-esi99A2RoZia6UaYBCuAgmlkgnY0iXNlY3AyNTZrMaECTUts0TYQMsqb0q652QCqTUXZ6tgKyUIzdMRRpyVNB2Y" | ||
}, | ||
{ | ||
"Address": "0x3325a78425F17a7E487Eb5666b2bFd93aBb06c70", | ||
"ENR": "enr:-HW4QDztNDqgEPAgJoHkcF4LfXyjXUo1r_xYoNv48H0PFItwYx-OnviqgfHxEz51RDOGvUMiTpXyo0HBjK5ZZ8YxS9WAgmlkgnY0iXNlY3AyNTZrMaECUx_mBoE0UD0nIxMyJ8hnrI-myDxTfppEw8W9vcsf4zc" | ||
}, | ||
{ | ||
"Address": "0xc48B812bB43401392c037381AcA934F4069C0517", | ||
"ENR": "enr:-HW4QGSS-HN3zRfCJGISFmDT59Cpo-daC4U2vSjqPZWegHVSJklFsDs0f1fF_E7X4q8NUbR3bWDlX7IifsjQ_Xrm7QuAgmlkgnY0iXNlY3AyNTZrMaEDRid5rUqtOVFGFHUacQhfLxDhx6WT5OAw77W4chzlWws" | ||
}, | ||
{ | ||
"Address": "0xd09Ad14080d4b257a819a4f579b8485Be88f086c", | ||
"ENR": "enr:-HW4QGFxPElPQZLydQ9Ach--g-jHJ0N4LO6uuIvyfw-Tg2K_R-R6iMCfzGryG80gmdPQwz9asajtn3CF88-rpu38YoKAgmlkgnY0iXNlY3AyNTZrMaEDYsCgRtrM6G3dA0PG08fHnCIIug2cnPJKbQRtIdIfkPc" | ||
} | ||
], | ||
"Validators": [ | ||
{ | ||
"PubKey": "o4nJ3v/2qlWFp2YNVor4JRQ7ytkRk36qbuIWfSJuEMIMjixY+q9f1ddJh5hErNcG", | ||
"PubShares": [ | ||
"ifSPWSihJJpTvdqoofhUO9JZM9myk1/5qiiy+Tc8J4AbRPRGNwfBfFfn/Lt8Yk5Z", | ||
"mer0HxEq9eL5/zSAMf0p/TvU9ww/lFzC1leR2RdFa9PrVFPtBZUPFcHP6AYjByOe", | ||
"s3D3UnDkGWDvETZrOEf1DHhgB31vZGPf7PlTW7jpL+sRSdmQbg4XAa1MGTxBrioK", | ||
"kAP3hEt7fLeRpLUi7TJngPArg+7wyf8HMDAV0o/CKcHXiw/REnwh71QfIk6+ZTqU" | ||
], | ||
"FeeRecipientAddress": "0x52fdfc072182654f163f5f0f9a621d729566c74d", | ||
"WithdrawalAddress": "0x81855ad8681d0d86d1e91e00167939cb6694d2c4" | ||
} | ||
] | ||
} |
Oops, something went wrong.