Files
chains/chain/fee_test.go
zeekay a93f6e3dec build the VMs without the daemon in their closure
A plugin is its own binary; the daemon that loads it has no business being
linked into it. Twelve VMs reached into github.com/luxfi/node for four things,
and each one now programs against a home that is actually its own:

- fee admission (Policy, FlatPolicy, NoUserTxPolicy, Validate) joins the
  settlement half already in chains/fee. One fee package, and the nodefee alias
  that marked the split is gone.
- the cross-chain artifact types move to chains/artifacts.
- the factory the daemon registers is luxfi/vm/manager.Factory, and the version
  types are luxfi/version. Both are ordinary modules the daemon reads too, so a
  VM imports them directly rather than through anything of ours.

The GPU switch is deleted, not moved. It was a global set during daemon startup
that a separate process could never observe, so every plugin read its default;
FHEOptions.Backend is the switch that was really there.

go list -deps names no luxfi/node for aivm, bridgevm, dexvm, evm, fhevm,
graphvm, identityvm, keyvm, mpcvm, quantumvm, schain or zkvm, and the built
plugin binaries carry no such string. oraclevm and relayvm still do: they are
re-export shims over luxfi/oracle and luxfi/relay, which build their fee
policies upstream. Their tests keep naming the daemon's fee package because
that is the type their value has.
2026-09-03 21:10:40 -07:00

47 lines
1.5 KiB
Go

// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package chain
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/luxfi/chains/fee"
)
func TestAChainThatChargesRefusesLessThanTheFloor(t *testing.T) {
f := Floor(1)
require.Error(t, f.Admit(0))
require.Error(t, f.Admit(fee.MinTxFeeFloor-1))
require.NoError(t, f.Admit(fee.MinTxFeeFloor))
require.NoError(t, f.Admit(fee.MinTxFeeFloor+1))
require.NoError(t, fee.Validate(f.Policy()),
"the node's boot-time check must accept what a user-facing chain declares")
}
func TestAClosedChainRefusesEveryCaller(t *testing.T) {
f := Closed()
require.ErrorIs(t, f.Admit(0), fee.ErrChainAcceptsNoUserTxs)
require.ErrorIs(t, f.Admit(fee.MinTxFeeFloor), fee.ErrChainAcceptsNoUserTxs)
require.ErrorIs(t, f.Admit(1<<62), fee.ErrChainAcceptsNoUserTxs)
require.NoError(t, fee.Validate(f.Policy()))
}
// TestAnUndeclaredFeeAdmitsNothing is the fail-closed shape: a chain that
// forgets to declare what it charges refuses every caller, rather than
// admitting every caller.
func TestAnUndeclaredFeeAdmitsNothing(t *testing.T) {
var f Fee
require.ErrorIs(t, f.Admit(0), fee.ErrChainAcceptsNoUserTxs)
require.ErrorIs(t, f.Admit(1<<62), fee.ErrChainAcceptsNoUserTxs)
require.Nil(t, f.Policy())
}
func TestTheFloorIsDenominatedInTheNetworksOwnAsset(t *testing.T) {
one, two := Floor(1), Floor(2)
require.NotEqual(t, one.asset, two.asset,
"two networks do not share an asset, so they do not share a floor")
}