Skip to content
Snippets Groups Projects
  • Hans Moog's avatar
    490f10e3
    Feat: Refactor and cleanup some code (#301) · 490f10e3
    Hans Moog authored
    * Feat: refactored the address
    
    * Feat: started adding solidification of transferOutputs
    
    * Feat: cleaned up checker code
    
    * Feat: going to bed - good night world
    
    * Feat: refactored transferoutput package
    
    * Fix: fixed a bug from refactoring
    
    * Refactor: removed old transferoutputmetadata package
    
    * Refactor: started refactoring transfer package
    
    * Refactor: refactored transfer/id package
    
    * Refactor: moved transfer struct to new package
    
    * Refactor: fixed issues after refactor
    
    * Refactor: fixed sth
    
    * Refactor: continued to move files
    
    * Refactor: commit before migration of last refactored files
    
    * Refactor: another refactor before move
    
    * Refactor: refactor test
    
    * Fix: fixed some bugs connected to refactor
    
    * Refactor: continued refactor
    
    * Refactor: fixed some bugs
    
    * Refactor: does it work now?
    
    * Feat: added a method to generate a random transferid
    
    * Feat: rename transfer to transaction
    
    * Refactor: refactor according to new names
    
    * Refactor: continued to refactor transaction package
    
    * Refactor: moved payload id to payload package
    
    * Refactor: moved signatures to transaction package
    
    * Refactor: moved signature to transaction
    
    * Fix: fixed bug due to refactor
    
    * Fix: fixed bugs due to refactor
    
    * Refactor: fixed some bugs after refactor
    
    * Fix: fixed additional bugs
    
    * Fix: bug fix
    
    * Refactor: moved signature to signaturescheme package
    
    * Fix: fixed signatures test
    
    * Fix: fixed bug in tangle
    
    * Fix: fixed payloadmetadata test
    
    * Fix: fixed payload test
    
    * Refactor: moved payloadmetadata to payload package
    
    * Fix: fixed some refactor bugs
    
    * Fix: fixed a bug due to refactor
    
    * Fix: fixed broken test
    
    * Refactor: moved approver to payload package
    
    * Refactor: moved missingpayload to payload package
    
    * Refactor: refactored coloredbalance package
    
    * Fix: fixed bug due to refactor
    
    * Refactor: moved address signaturescheme to address package
    
    * Fix: fixed refactor bug
    
    * Feat: added missing outputs to tangle
    
    * Fix: fixed issues due to refactor
    
    * Refactor: started moving tangle classes to tangle package
    
    * Refactor: moved payloadmetadata to tangle
    
    * Fix: fixed bugs due to refactor
    
    * Refactor: moved TransactionMetadata to tangle package
    
    * Refactor: moved some files to tangle
    
    * Fix: fixed bug due to refactor
    
    * Feat: added TransactionMetadata storage
    
    * Fix: fixed some issues
    
    * Fix: fixed some issues
    
    * Fix: fixed missing release
    Feat: Refactor and cleanup some code (#301)
    Hans Moog authored
    * Feat: refactored the address
    
    * Feat: started adding solidification of transferOutputs
    
    * Feat: cleaned up checker code
    
    * Feat: going to bed - good night world
    
    * Feat: refactored transferoutput package
    
    * Fix: fixed a bug from refactoring
    
    * Refactor: removed old transferoutputmetadata package
    
    * Refactor: started refactoring transfer package
    
    * Refactor: refactored transfer/id package
    
    * Refactor: moved transfer struct to new package
    
    * Refactor: fixed issues after refactor
    
    * Refactor: fixed sth
    
    * Refactor: continued to move files
    
    * Refactor: commit before migration of last refactored files
    
    * Refactor: another refactor before move
    
    * Refactor: refactor test
    
    * Fix: fixed some bugs connected to refactor
    
    * Refactor: continued refactor
    
    * Refactor: fixed some bugs
    
    * Refactor: does it work now?
    
    * Feat: added a method to generate a random transferid
    
    * Feat: rename transfer to transaction
    
    * Refactor: refactor according to new names
    
    * Refactor: continued to refactor transaction package
    
    * Refactor: moved payload id to payload package
    
    * Refactor: moved signatures to transaction package
    
    * Refactor: moved signature to transaction
    
    * Fix: fixed bug due to refactor
    
    * Fix: fixed bugs due to refactor
    
    * Refactor: fixed some bugs after refactor
    
    * Fix: fixed additional bugs
    
    * Fix: bug fix
    
    * Refactor: moved signature to signaturescheme package
    
    * Fix: fixed signatures test
    
    * Fix: fixed bug in tangle
    
    * Fix: fixed payloadmetadata test
    
    * Fix: fixed payload test
    
    * Refactor: moved payloadmetadata to payload package
    
    * Fix: fixed some refactor bugs
    
    * Fix: fixed a bug due to refactor
    
    * Fix: fixed broken test
    
    * Refactor: moved approver to payload package
    
    * Refactor: moved missingpayload to payload package
    
    * Refactor: refactored coloredbalance package
    
    * Fix: fixed bug due to refactor
    
    * Refactor: moved address signaturescheme to address package
    
    * Fix: fixed refactor bug
    
    * Feat: added missing outputs to tangle
    
    * Fix: fixed issues due to refactor
    
    * Refactor: started moving tangle classes to tangle package
    
    * Refactor: moved payloadmetadata to tangle
    
    * Fix: fixed bugs due to refactor
    
    * Refactor: moved TransactionMetadata to tangle package
    
    * Refactor: moved some files to tangle
    
    * Fix: fixed bug due to refactor
    
    * Feat: added TransactionMetadata storage
    
    * Fix: fixed some issues
    
    * Fix: fixed some issues
    
    * Fix: fixed missing release
payloadmetadata_test.go 1.49 KiB
package tangle

import (
	"testing"
	"time"

	"github.com/stretchr/testify/assert"

	"github.com/iotaledger/goshimmer/packages/binary/valuetransfer/payload"
)

func TestMarshalUnmarshal(t *testing.T) {
	originalMetadata := NewPayloadMetadata(payload.GenesisId)

	clonedMetadata, err, _ := PayloadMetadataFromBytes(originalMetadata.Bytes())
	if err != nil {
		panic(err)
	}

	assert.Equal(t, originalMetadata.GetPayloadId(), clonedMetadata.GetPayloadId())
	assert.Equal(t, originalMetadata.IsSolid(), clonedMetadata.IsSolid())
	assert.Equal(t, originalMetadata.GetSoldificationTime().Round(time.Second), clonedMetadata.GetSoldificationTime().Round(time.Second))

	originalMetadata.SetSolid(true)

	clonedMetadata, err, _ = PayloadMetadataFromBytes(originalMetadata.Bytes())
	if err != nil {
		panic(err)
	}

	assert.Equal(t, originalMetadata.GetPayloadId(), clonedMetadata.GetPayloadId())
	assert.Equal(t, originalMetadata.IsSolid(), clonedMetadata.IsSolid())
	assert.Equal(t, originalMetadata.GetSoldificationTime().Round(time.Second), clonedMetadata.GetSoldificationTime().Round(time.Second))
}

func TestPayloadMetadata_SetSolid(t *testing.T) {
	originalMetadata := NewPayloadMetadata(payload.GenesisId)

	assert.Equal(t, false, originalMetadata.IsSolid())
	assert.Equal(t, time.Time{}, originalMetadata.GetSoldificationTime())

	originalMetadata.SetSolid(true)

	assert.Equal(t, true, originalMetadata.IsSolid())
	assert.Equal(t, time.Now().Round(time.Second), originalMetadata.GetSoldificationTime().Round(time.Second))
}