status-im/status-go

View on GitHub
mailserver/db_key_test.go

Summary

Maintainability
A
0 mins
Test Coverage
package mailserver

import (
    "testing"

    "github.com/stretchr/testify/require"

    "github.com/status-im/status-go/eth-node/types"
)

func TestNewDBKey(t *testing.T) {
    topic := types.BytesToTopic([]byte{0x01, 0x02, 0x03, 0x04})

    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})
    dbKey := NewDBKey(0xabcdef12, topic, hash)
    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}
    require.Equal(t, expected, dbKey.Bytes())
    require.Equal(t, topic, dbKey.Topic())
    require.Equal(t, hash, dbKey.EnvelopeHash())
}