39 lines
729 B
Go
39 lines
729 B
Go
package transactions_test
|
|
|
|
import (
|
|
"dejo_node/internal/transactions"
|
|
"testing"
|
|
)
|
|
|
|
func TestTransaction_Hash(t *testing.T) {
|
|
tx := transactions.Transaction{
|
|
From: "0xabc",
|
|
To: "0xdef",
|
|
Value: 100,
|
|
Nonce: 1,
|
|
Gas: 21000,
|
|
Signature: "0xsig",
|
|
}
|
|
|
|
hash := tx.Hash()
|
|
if hash == "" {
|
|
t.Fatal("hash não pode ser vazio")
|
|
}
|
|
}
|
|
|
|
func TestTransaction_IsZero(t *testing.T) {
|
|
tx := transactions.Transaction{}
|
|
if !tx.IsZero() {
|
|
t.Error("transação vazia deveria retornar true para IsZero")
|
|
}
|
|
|
|
tx = transactions.Transaction{
|
|
From: "0xabc",
|
|
To: "0xdef",
|
|
Value: 10,
|
|
Signature: "0xsig",
|
|
}
|
|
if tx.IsZero() {
|
|
t.Error("transação válida retornou true para IsZero")
|
|
}
|
|
} |