package transactions_test import ( "dejo_node/internal/transactions" "testing" ) func TestMempool_AddAndGet(t *testing.T) { pool := transactions.NewMempool() tx := &transactions.Transaction{ From: "0xabc", To: "0xdef", Nonce: 1, Value: 10, Gas: 1, Signature: "sig", } err := pool.Add(tx) if err != nil { t.Fatalf("erro ao adicionar transação: %v", err) } txs := pool.All() if len(txs) != 1 { t.Errorf("esperava 1 transação, obteve %d", len(txs)) } if !pool.Has(tx.Hash()) { t.Error("transação deveria existir na mempool") } } func TestMempool_Duplicates(t *testing.T) { pool := transactions.NewMempool() tx := &transactions.Transaction{From: "0xaaa", Nonce: 1} _ = pool.Add(tx) err := pool.Add(tx) if err == nil { t.Error("esperava erro de transação duplicada") } } func TestMempool_Remove(t *testing.T) { pool := transactions.NewMempool() tx := &transactions.Transaction{From: "0xaaa", Nonce: 2} _ = pool.Add(tx) pool.Remove(tx.Hash()) if pool.Has(tx.Hash()) { t.Error("transação ainda existe após remoção") } }