-
Hans Moog authored
* Refactor: cleaned up unused files * Refactor: changing branches (need to commit) * Refactor: refactored some code * Feat: finished signature scheme for value transactions * Fix: fix broken merge * Refactor: refactored some code * Refactor: refactored transaction marshaling and unmarshaling * Fix: fixed missing err check * Feat: added payload string method * Feat: added Bytes() method to transactionid * Feat: refactored the marshaling * Refactor: refactored serialization code * Feat: started implementing the payload metadata * Docs: added some doc comments * Docs: added some additional docs * Feat: added a CachedObject of the payloadmetadata + added comments * Feat: updated hive.go + added further models * Feat: pc died - rescued files from disk * Feat: further models implemented * Feat: added missing model for value tangle * Feat: started writing test cases for value tangle * Feat: started to adjust marshaling of transaction * Feat: refactored marshaling of payload * Feat: intermediary commit before bigger refactor * Feat: removed identity package * Fix: fixed bugs due to refactor * Fix: fixed further bugs * Fix: fixed further bugs * Fix: hopefully last bugs :p * Feat: changed time marshal to use nanoseconds * Fix: fixed time marshaling * Fix: fixed serialization bug * Docs: added a comment to handling the zero value * Refactor: refactored transaction to separate issuerKey * Feat: added a parse method for Signatures * Feat: updated to latest hive.go
Hans Moog authored* Refactor: cleaned up unused files * Refactor: changing branches (need to commit) * Refactor: refactored some code * Feat: finished signature scheme for value transactions * Fix: fix broken merge * Refactor: refactored some code * Refactor: refactored transaction marshaling and unmarshaling * Fix: fixed missing err check * Feat: added payload string method * Feat: added Bytes() method to transactionid * Feat: refactored the marshaling * Refactor: refactored serialization code * Feat: started implementing the payload metadata * Docs: added some doc comments * Docs: added some additional docs * Feat: added a CachedObject of the payloadmetadata + added comments * Feat: updated hive.go + added further models * Feat: pc died - rescued files from disk * Feat: further models implemented * Feat: added missing model for value tangle * Feat: started writing test cases for value tangle * Feat: started to adjust marshaling of transaction * Feat: refactored marshaling of payload * Feat: intermediary commit before bigger refactor * Feat: removed identity package * Fix: fixed bugs due to refactor * Fix: fixed further bugs * Fix: fixed further bugs * Fix: hopefully last bugs :p * Feat: changed time marshal to use nanoseconds * Fix: fixed time marshaling * Fix: fixed serialization bug * Docs: added a comment to handling the zero value * Refactor: refactored transaction to separate issuerKey * Feat: added a parse method for Signatures * Feat: updated to latest hive.go
tipselector_test.go 1.78 KiB
package tipselector
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/iotaledger/goshimmer/packages/binary/signature/ed25119"
"github.com/iotaledger/goshimmer/packages/binary/tangle/model/transaction"
"github.com/iotaledger/goshimmer/packages/binary/tangle/model/transaction/payload/data"
)
func Test(t *testing.T) {
// create tip selector
tipSelector := New()
// check if first tips point to genesis
trunk1, branch1 := tipSelector.GetTips()
assert.Equal(t, transaction.EmptyId, trunk1)
assert.Equal(t, transaction.EmptyId, branch1)
// create a transaction and attach it
transaction1 := transaction.New(trunk1, branch1, ed25119.GenerateKeyPair(), data.New([]byte("testtransaction")))
tipSelector.AddTip(transaction1)
// check if the tip shows up in the tip count
assert.Equal(t, 1, tipSelector.GetTipCount())
// check if next tips point to our first transaction
trunk2, branch2 := tipSelector.GetTips()
assert.Equal(t, transaction1.GetId(), trunk2)
assert.Equal(t, transaction1.GetId(), branch2)
// create a 2nd transaction and attach it
transaction2 := transaction.New(transaction.EmptyId, transaction.EmptyId, ed25119.GenerateKeyPair(), data.New([]byte("testtransaction")))
tipSelector.AddTip(transaction2)
// check if the tip shows up in the tip count
assert.Equal(t, 2, tipSelector.GetTipCount())
// attach a transaction to our two tips
trunk3, branch3 := tipSelector.GetTips()
transaction3 := transaction.New(trunk3, branch3, ed25119.GenerateKeyPair(), data.New([]byte("testtransaction")))
tipSelector.AddTip(transaction3)
// check if the tip shows replaces the current tips
trunk4, branch4 := tipSelector.GetTips()
assert.Equal(t, 1, tipSelector.GetTipCount())
assert.Equal(t, transaction3.GetId(), trunk4)
assert.Equal(t, transaction3.GetId(), branch4)
}