commit inicial do projeto

This commit is contained in:
Júnior
2025-05-23 10:44:32 -03:00
commit 8f04473c0b
106 changed files with 5673 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package transactions_test
import (
"dejo_node/internal/transactions"
"testing"
)
func TestCreateBlock(t *testing.T) {
tx1 := &transactions.Transaction{
From: "A",
To: "B",
Value: 10,
Nonce: 1,
Gas: 1,
Signature: "sig1",
}
tx2 := &transactions.Transaction{
From: "B",
To: "C",
Value: 5,
Nonce: 1,
Gas: 1,
Signature: "sig2",
}
block := transactions.CreateBlock("prevhash", []*transactions.Transaction{tx1, tx2}, 2)
if block.Hash == "" {
t.Error("hash do bloco não pode ser vazio")
}
if block.Index != 2 {
t.Errorf("esperava índice 2, obteve %d", block.Index)
}
if block.PrevHash != "prevhash" {
t.Errorf("hash anterior incorreto")
}
if len(block.Txns) != 2 {
t.Errorf("esperava 2 transações no bloco, obteve %d", len(block.Txns))
}
}