mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
xvm: preserve nanosecond Duration wire format for v2
xvm.Config embeds network.Config which has time.Duration fields. v1 encoded these as integer nanoseconds; v2 has no default representation. Pass jsonv1.FormatDurationAsNano(true) at ParseConfig and at the test marshal sites so the wire format is preserved.
This commit is contained in:
+2
-1
@@ -5,6 +5,7 @@ package xvm
|
||||
|
||||
import (
|
||||
"github.com/go-json-experiment/json"
|
||||
jsonv1 "github.com/go-json-experiment/json/v1"
|
||||
|
||||
"github.com/luxfi/node/vms/xvm/config"
|
||||
"github.com/luxfi/node/vms/xvm/network"
|
||||
@@ -31,6 +32,6 @@ func ParseConfig(configBytes []byte) (Config, error) {
|
||||
}
|
||||
|
||||
cfg := DefaultConfig
|
||||
err := json.Unmarshal(configBytes, &cfg)
|
||||
err := json.Unmarshal(configBytes, &cfg, jsonv1.FormatDurationAsNano(true))
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package xvm
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-json-experiment/json"
|
||||
jsonv1 "github.com/go-json-experiment/json/v1"
|
||||
"errors"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -73,7 +74,7 @@ func TestXVMInitialize_WiresSecurityProfileIntoMempool(t *testing.T) {
|
||||
&vm.Fx{ID: propertyfx.ID, Fx: &propertyfx.Fx{}},
|
||||
}
|
||||
|
||||
configBytes, err := json.Marshal(DefaultConfig)
|
||||
configBytes, err := json.Marshal(DefaultConfig, jsonv1.FormatDurationAsNano(true))
|
||||
require.NoError(err)
|
||||
|
||||
require.NoError(vmImpl.Initialize(
|
||||
|
||||
@@ -6,6 +6,7 @@ package xvm
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-json-experiment/json"
|
||||
jsonv1 "github.com/go-json-experiment/json/v1"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
@@ -269,7 +270,7 @@ func setup(t testing.TB, config *envConfig) *testEnv {
|
||||
if config.indexTransactions {
|
||||
vmConfig.IndexTransactions = true
|
||||
}
|
||||
configBytes, err := json.Marshal(vmConfig)
|
||||
configBytes, err := json.Marshal(vmConfig, jsonv1.FormatDurationAsNano(true))
|
||||
require.NoError(err)
|
||||
|
||||
toEngine := make(chan vm.Message, 1)
|
||||
|
||||
Reference in New Issue
Block a user