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:
Hanzo AI
2026-06-06 23:06:41 -07:00
parent 96fc5e58e5
commit 8cf6c53246
3 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -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
}
+2 -1
View File
@@ -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(
+2 -1
View File
@@ -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)