mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
The module already called itself github.com/luxfi/node while containing no node in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and the Go column of the matrix measured a VM plugin. A repo that fetches the thing it claims to be has not replaced it, so the Go sources move in — 1515 files, the daemon and everything under it — and the build reaches outside this module for nothing. Rust and C++ sit beside it unchanged and are still measured against it by the differential. That is the point of one repo: the reference implementation and the two ports are the same checkout, so parity is a thing you can run rather than a thing you assert. Verified: builds, and the closure carries no lux-private — checked at build time rather than believed. The daemon starts twelve chains on a local network (P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
91 lines
3.0 KiB
Go
91 lines
3.0 KiB
Go
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package mempool
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/luxfi/consensus/config"
|
|
"github.com/luxfi/metric"
|
|
"github.com/luxfi/node/vms/components/verify"
|
|
"github.com/luxfi/node/vms/txs/auth"
|
|
"github.com/luxfi/utxo/secp256k1fx"
|
|
)
|
|
|
|
// TestMempoolAdd_StrictPQ_RefusesClassicalCredentials verifies that the
|
|
// P-chain mempool refuses a tx whose credentials carry a classical
|
|
// secp256k1fx.Credential when the chain's profile pins
|
|
// RequireTypedTxAuth=true and no ClassicalCompatRegistry names the
|
|
// originator. This is the mempool-level enforcement of the F-class
|
|
// objection: a strict-PQ chain MUST NOT gossip a classical-credential
|
|
// tx.
|
|
func TestMempoolAdd_StrictPQ_RefusesClassicalCredentials(t *testing.T) {
|
|
mpool, err := New("test", metric.NewRegistry())
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
|
|
// Pin strict-PQ; supply no registry so every classical credential
|
|
// is refused.
|
|
mpool.SetAuthPolicy(&config.ChainSecurityProfile{RequireTypedTxAuth: true}, nil)
|
|
|
|
decisions, err := createTestDecisionTxs(1)
|
|
if err != nil {
|
|
t.Fatalf("createTestDecisionTxs: %v", err)
|
|
}
|
|
tx := decisions[0]
|
|
// createTestDecisionTxs leaves Creds empty; inject a single
|
|
// classical credential to exercise the gate.
|
|
tx.Creds = []verify.Verifiable{&secp256k1fx.Credential{}}
|
|
|
|
if err := mpool.Add(tx); !errors.Is(err, auth.ErrLegacyCredentialUnderStrictPQ) {
|
|
t.Fatalf("mempool.Add: got %v, want ErrLegacyCredentialUnderStrictPQ", err)
|
|
}
|
|
}
|
|
|
|
// TestMempoolAdd_NoPolicy_AdmitsClassicalCredentials confirms backward
|
|
// compatibility — a mempool that has never called SetAuthPolicy admits
|
|
// classical credentials unchanged. This is the path every existing
|
|
// caller follows today; the new gate is opt-in.
|
|
func TestMempoolAdd_NoPolicy_AdmitsClassicalCredentials(t *testing.T) {
|
|
mpool, err := New("test", metric.NewRegistry())
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
|
|
decisions, err := createTestDecisionTxs(1)
|
|
if err != nil {
|
|
t.Fatalf("createTestDecisionTxs: %v", err)
|
|
}
|
|
tx := decisions[0]
|
|
tx.Creds = []verify.Verifiable{&secp256k1fx.Credential{}}
|
|
|
|
if err := mpool.Add(tx); err != nil {
|
|
t.Fatalf("mempool.Add: %v (expected admission)", err)
|
|
}
|
|
}
|
|
|
|
// TestMempoolAdd_ClassicalCompatProfile_AdmitsClassicalCredentials
|
|
// proves the gate is a no-op when the chain pins
|
|
// RequireTypedTxAuth=false (the classical-compat profile path).
|
|
func TestMempoolAdd_ClassicalCompatProfile_AdmitsClassicalCredentials(t *testing.T) {
|
|
mpool, err := New("test", metric.NewRegistry())
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
mpool.SetAuthPolicy(&config.ChainSecurityProfile{RequireTypedTxAuth: false}, nil)
|
|
|
|
decisions, err := createTestDecisionTxs(1)
|
|
if err != nil {
|
|
t.Fatalf("createTestDecisionTxs: %v", err)
|
|
}
|
|
tx := decisions[0]
|
|
tx.Creds = []verify.Verifiable{&secp256k1fx.Credential{}}
|
|
|
|
if err := mpool.Add(tx); err != nil {
|
|
t.Fatalf("mempool.Add: %v (expected admission under classical-compat)", err)
|
|
}
|
|
}
|