commit inicial do projeto
This commit is contained in:
39
internal/transactions/transaction_test.go
Normal file
39
internal/transactions/transaction_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user