* remove assetDataUtils everywhere * export IAssetDataContract from @0x/contract-wrappers to allow @0x/instant to decode asset data synchronously * export generic function `decodeAssetDataOrThrow` and add ERC20Bridge support * export `hexUtils` from order-utils instead of contracts-test-utils
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { blockchainTests, expect } from '@0x/contracts-test-utils';
 | |
| import { coerceThrownErrorAsRevertError, hexUtils, StringRevertError } from '@0x/utils';
 | |
| 
 | |
| import { artifacts } from './artifacts';
 | |
| import { TestLibRichErrorsContract } from './wrappers';
 | |
| 
 | |
| blockchainTests('LibRichErrors', env => {
 | |
|     let lib: TestLibRichErrorsContract;
 | |
| 
 | |
|     before(async () => {
 | |
|         // Deploy SafeMath
 | |
|         lib = await TestLibRichErrorsContract.deployFrom0xArtifactAsync(
 | |
|             artifacts.TestLibRichErrors,
 | |
|             env.provider,
 | |
|             env.txDefaults,
 | |
|             {},
 | |
|         );
 | |
|     });
 | |
| 
 | |
|     describe('_rrevert', () => {
 | |
|         it('should correctly revert the extra bytes', async () => {
 | |
|             const extraBytes = hexUtils.random(100);
 | |
|             try {
 | |
|                 await lib.externalRRevert(extraBytes).callAsync();
 | |
|             } catch (err) {
 | |
|                 const revertError = coerceThrownErrorAsRevertError(err);
 | |
|                 return expect(revertError.encode()).to.eq(extraBytes);
 | |
|             }
 | |
|             return;
 | |
|             // TODO(xianny): NOT WORKING, v3 merge
 | |
|             // return expect.fail('Expected call to revert');
 | |
|         });
 | |
| 
 | |
|         it('should correctly revert a StringRevertError', async () => {
 | |
|             const error = new StringRevertError('foo');
 | |
|             return expect(lib.externalRRevert(error.encode()).callAsync()).to.revertWith(error);
 | |
|         });
 | |
|     });
 | |
| });
 |