* Add Base64 library to utils * Fix typo on Base64 padding * Added documentation for Base64 and references from ERC1155 and ERC721 * Updated Changelog * Fix typo in utilities doc * use mstore8 to improve memory accesses * use shorter strings with encodePacked * do not use using-for syntax, for clarity Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com> Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
30 lines
1021 B
JavaScript
30 lines
1021 B
JavaScript
const { expect } = require('chai');
|
|
|
|
const Base64Mock = artifacts.require('Base64Mock');
|
|
|
|
contract('Strings', function () {
|
|
beforeEach(async function () {
|
|
this.base64 = await Base64Mock.new();
|
|
});
|
|
|
|
describe('from bytes - base64', function () {
|
|
it('converts to base64 encoded string with double padding', async function () {
|
|
const TEST_MESSAGE = 'test';
|
|
const input = web3.utils.asciiToHex(TEST_MESSAGE);
|
|
expect(await this.base64.encode(input)).to.equal('dGVzdA==');
|
|
});
|
|
|
|
it('converts to base64 encoded string with single padding', async function () {
|
|
const TEST_MESSAGE = 'test1';
|
|
const input = web3.utils.asciiToHex(TEST_MESSAGE);
|
|
expect(await this.base64.encode(input)).to.equal('dGVzdDE=');
|
|
});
|
|
|
|
it('converts to base64 encoded string without padding', async function () {
|
|
const TEST_MESSAGE = 'test12';
|
|
const input = web3.utils.asciiToHex(TEST_MESSAGE);
|
|
expect(await this.base64.encode(input)).to.equal('dGVzdDEy');
|
|
});
|
|
});
|
|
});
|