github.com/status-im/status-go@v1.1.0/mailserver/db_key_test.go (about)

     1  package mailserver
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	"github.com/status-im/status-go/eth-node/types"
     9  )
    10  
    11  func TestNewDBKey(t *testing.T) {
    12  	topic := types.BytesToTopic([]byte{0x01, 0x02, 0x03, 0x04})
    13  
    14  	hash := types.BytesToHash([]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31, 0x32})
    15  	dbKey := NewDBKey(0xabcdef12, topic, hash)
    16  	expected := []byte{0xab, 0xcd, 0xef, 0x12, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31, 0x32, 0x01, 0x02, 0x03, 0x04}
    17  	require.Equal(t, expected, dbKey.Bytes())
    18  	require.Equal(t, topic, dbKey.Topic())
    19  	require.Equal(t, hash, dbKey.EnvelopeHash())
    20  }