@@ -2,6 +2,7 @@ const { ethers } = require('hardhat');
2
2
const { expect } = require ( 'chai' ) ;
3
3
const { loadFixture } = require ( '@nomicfoundation/hardhat-network-helpers' ) ;
4
4
const { MAX_UINT128 , MAX_UINT64 , MAX_UINT32 , MAX_UINT16 } = require ( '../helpers/constants' ) ;
5
+ const { generators } = require ( '../helpers/random' ) ;
5
6
6
7
// Helper functions for fixed bytes types
7
8
const bytes32 = value => ethers . toBeHex ( value , 32 ) ;
@@ -112,6 +113,47 @@ describe('Bytes', function () {
112
113
} ) ;
113
114
} ) ;
114
115
116
+ describe ( 'concat' , function ( ) {
117
+ it ( 'empty list' , async function ( ) {
118
+ await expect ( this . mock . $concat ( [ ] ) ) . to . eventually . equal ( generators . bytes . zero ) ;
119
+ } ) ;
120
+
121
+ it ( 'single item' , async function ( ) {
122
+ const item = generators . bytes ( ) ;
123
+ await expect ( this . mock . $concat ( [ item ] ) ) . to . eventually . equal ( item ) ;
124
+ } ) ;
125
+
126
+ it ( 'multiple (non-empty) items' , async function ( ) {
127
+ const items = Array . from ( { length : 17 } , generators . bytes ) ;
128
+ await expect ( this . mock . $concat ( items ) ) . to . eventually . equal ( ethers . concat ( items ) ) ;
129
+ } ) ;
130
+
131
+ it ( 'multiple (empty) items' , async function ( ) {
132
+ const items = Array . from ( { length : 17 } ) . fill ( generators . bytes . zero ) ;
133
+ await expect ( this . mock . $concat ( items ) ) . to . eventually . equal ( ethers . concat ( items ) ) ;
134
+ } ) ;
135
+
136
+ it ( 'multiple (variable length) items' , async function ( ) {
137
+ const items = [
138
+ generators . bytes . zero ,
139
+ generators . bytes ( 17 ) ,
140
+ generators . bytes . zero ,
141
+ generators . bytes ( 42 ) ,
142
+ generators . bytes ( 1 ) ,
143
+ generators . bytes ( 256 ) ,
144
+ generators . bytes ( 1024 ) ,
145
+ generators . bytes . zero ,
146
+ generators . bytes ( 7 ) ,
147
+ generators . bytes ( 15 ) ,
148
+ generators . bytes ( 63 ) ,
149
+ generators . bytes . zero ,
150
+ generators . bytes . zero ,
151
+ ] ;
152
+
153
+ await expect ( this . mock . $concat ( items ) ) . to . eventually . equal ( ethers . concat ( items ) ) ;
154
+ } ) ;
155
+ } ) ;
156
+
115
157
describe ( 'clz bytes' , function ( ) {
116
158
it ( 'empty buffer' , async function ( ) {
117
159
await expect ( this . mock . $clz ( '0x' ) ) . to . eventually . equal ( 0 ) ;
0 commit comments