You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
624 B

  1. package types
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/require"
  5. "github.com/tendermint/tendermint/libs/bits"
  6. )
  7. func TestCopy(t *testing.T) {
  8. t.Run("VerifyShallowCopy", func(t *testing.T) {
  9. prsOne := PeerRoundState{}
  10. prsOne.Prevotes = bits.NewBitArray(12)
  11. prsTwo := prsOne
  12. prsOne.Prevotes.SetIndex(1, true)
  13. require.Equal(t, prsOne.Prevotes, prsTwo.Prevotes)
  14. })
  15. t.Run("DeepCopy", func(t *testing.T) {
  16. prsOne := PeerRoundState{}
  17. prsOne.Prevotes = bits.NewBitArray(12)
  18. prsTwo := prsOne.Copy()
  19. prsOne.Prevotes.SetIndex(1, true)
  20. require.NotEqual(t, prsOne.Prevotes, prsTwo.Prevotes)
  21. })
  22. }