|
| 1 | +package blockchain_messages |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/stretchr/testify/assert" |
| 7 | +) |
| 8 | + |
| 9 | +func TestOneCorrId(t *testing.T) { |
| 10 | + t.Parallel() |
| 11 | + |
| 12 | + descriptor := &BlockMessageDescriptor{ |
| 13 | + TransactionHashes: []string{ |
| 14 | + "0x1234567890123456789012345678901234567890123456789012345678901234", |
| 15 | + }, |
| 16 | + } |
| 17 | + |
| 18 | + assert.Equal(t, []byte("0"), descriptor.CorrelationId()) |
| 19 | + |
| 20 | + descriptor = &BlockMessageDescriptor{ |
| 21 | + TransactionHashes: []string{ |
| 22 | + "0x1234567890123456789012345678901234567890123456789012345678901235", |
| 23 | + }, |
| 24 | + } |
| 25 | + |
| 26 | + assert.Equal(t, []byte("1"), descriptor.CorrelationId()) |
| 27 | + |
| 28 | + descriptor = &BlockMessageDescriptor{ |
| 29 | + TransactionHashes: []string{ |
| 30 | + "0x1234567890123456789012345678901234567890123456789012345678901236", |
| 31 | + }, |
| 32 | + } |
| 33 | + |
| 34 | + assert.Equal(t, []byte("2"), descriptor.CorrelationId()) |
| 35 | + |
| 36 | + descriptor = &BlockMessageDescriptor{ |
| 37 | + TransactionHashes: []string{ |
| 38 | + "0x1234567890123456789012345678901234567890123456789012345678901237", |
| 39 | + }, |
| 40 | + } |
| 41 | + |
| 42 | + assert.Equal(t, []byte("3"), descriptor.CorrelationId()) |
| 43 | +} |
| 44 | + |
| 45 | +func TestManyCorrId(t *testing.T) { |
| 46 | + t.Parallel() |
| 47 | + |
| 48 | + descriptor := &BlockMessageDescriptor{ |
| 49 | + TransactionHashes: []string{ |
| 50 | + "0x1234567890123456789012345678901234567890123456789012345678901234", |
| 51 | + "0x1234567890123456789012345678901234567890123456789012345678901238", |
| 52 | + "0x123456789012345678901234567890123456789012345678901234567890123c", |
| 53 | + }, |
| 54 | + } |
| 55 | + |
| 56 | + assert.Equal(t, []byte("0"), descriptor.CorrelationId()) |
| 57 | + |
| 58 | + descriptor = &BlockMessageDescriptor{ |
| 59 | + TransactionHashes: []string{ |
| 60 | + "0x1234567890123456789012345678901234567890123456789012345678901235", |
| 61 | + "0x1234567890123456789012345678901234567890123456789012345678901234", |
| 62 | + }, |
| 63 | + } |
| 64 | + |
| 65 | + assert.Nil(t, descriptor.CorrelationId()) |
| 66 | + |
| 67 | + descriptor = &BlockMessageDescriptor{ |
| 68 | + TransactionHashes: []string{ |
| 69 | + "0xb432db11c6c6460f6bbf951a71b3ea3df9e0e414c1a4616728795111a7518f30", |
| 70 | + "0x74d35692f26ae3b6f0d276091a73093205b31ed320f127d5ce4c6454a250d98c", |
| 71 | + "0x8140ba1c7ea8104437e7c576fc43cb05d75276dcff3d99eec83ba7c4784787a8", |
| 72 | + "0x74a96c3df0649f9e3de102da99f2e6cac350c1537e5643e6c20b5b8b57dbf73c", |
| 73 | + }, |
| 74 | + } |
| 75 | + |
| 76 | + assert.Equal(t, []byte("0"), descriptor.CorrelationId()) |
| 77 | + |
| 78 | + descriptor = &BlockMessageDescriptor{ |
| 79 | + TransactionHashes: []string{ |
| 80 | + "0xd051e1a031d589ad246518525b792518984301ca5e833bbf64719783b20cc662", |
| 81 | + "0xad4f25e8a958dfd99baabf1a2479dda2765ecb05feb17efe2996331dc3eb5f4a", |
| 82 | + }, |
| 83 | + } |
| 84 | + |
| 85 | + assert.Equal(t, []byte("2"), descriptor.CorrelationId()) |
| 86 | + |
| 87 | + descriptor = &BlockMessageDescriptor{ |
| 88 | + TransactionHashes: []string{ |
| 89 | + "0x1ed6796ba1bfae3e6c3ea00c077e3fb7e24522c6f7d332148ed248f15cd748f9", |
| 90 | + "0x9724e6f6835be2aad985bfe51a0b8498b20b49f71f1001394005913dc7a371a1", |
| 91 | + }, |
| 92 | + } |
| 93 | + |
| 94 | + assert.Equal(t, []byte("1"), descriptor.CorrelationId()) |
| 95 | + |
| 96 | + descriptor = &BlockMessageDescriptor{ |
| 97 | + TransactionHashes: []string{ |
| 98 | + "0x97026efd8249efac39bd45750b40baeb3a2def0357ceb1779797edf4802bd8be", |
| 99 | + "0xd7bebfb0968ad3f385dc2971ed9314bda30fa063a3969e14a5ca7a884bdd4402", |
| 100 | + }, |
| 101 | + } |
| 102 | + |
| 103 | + assert.Equal(t, []byte("2"), descriptor.CorrelationId()) |
| 104 | +} |
0 commit comments