@Test public void readFromFileThatIsTooLarge() throws URISyntaxException, DeserializationException, IOException { File file = new File(Objects.requireNonNull(NefFileTest.class.getClassLoader() .getResource("contracts/too_large.nef")).toURI()); expectedException.expect(IllegalArgumentException.class); NefFile.readFromFile(file); }
public static NefFile readFromFile(File nefFile) throws DeserializationException, IOException { int nefFileSize = (int) nefFile.length(); if (nefFileSize > 0x100000) { throw new IllegalArgumentException("The given NEF file is too large. File was " + nefFileSize + " bytes, but a max of 2^20 bytes is allowed."); } try (FileInputStream nefStream = new FileInputStream(nefFile)) { BinaryReader reader = new BinaryReader(nefStream); return reader.readSerializable(NefFile.class); } }
NefFile extends NeoSerializable { public static NefFile readFromFile(File nefFile) throws DeserializationException, IOException { int nefFileSize = (int) nefFile.length(); if (nefFileSize > 0x100000) { throw new IllegalArgumentException("The given NEF file is too large. File was " + nefFileSize + " bytes, but a max of 2^20 bytes is allowed."); } try (FileInputStream nefStream = new FileInputStream(nefFile)) { BinaryReader reader = new BinaryReader(nefStream); return reader.readSerializable(NefFile.class); } } }
NefFile extends NeoSerializable { public static NefFile readFromFile(File nefFile) throws DeserializationException, IOException { int nefFileSize = (int) nefFile.length(); if (nefFileSize > 0x100000) { throw new IllegalArgumentException("The given NEF file is too large. File was " + nefFileSize + " bytes, but a max of 2^20 bytes is allowed."); } try (FileInputStream nefStream = new FileInputStream(nefFile)) { BinaryReader reader = new BinaryReader(nefStream); return reader.readSerializable(NefFile.class); } } NefFile();  NefFile(String compiler, Version version, byte[] script); }
NefFile extends NeoSerializable { public static NefFile readFromFile(File nefFile) throws DeserializationException, IOException { int nefFileSize = (int) nefFile.length(); if (nefFileSize > 0x100000) { throw new IllegalArgumentException("The given NEF file is too large. File was " + nefFileSize + " bytes, but a max of 2^20 bytes is allowed."); } try (FileInputStream nefStream = new FileInputStream(nefFile)) { BinaryReader reader = new BinaryReader(nefStream); return reader.readSerializable(NefFile.class); } } NefFile();  NefFile(String compiler, Version version, byte[] script); String getCompiler(); Version getVersion(); ScriptHash getScriptHash(); byte[] getCheckSum(); byte[] getScript(); @Override int getSize(); @Override void serialize(BinaryWriter writer); @Override void deserialize(BinaryReader reader); static byte[] computeChecksum(NefFile file); static NefFile readFromFile(File nefFile); }
NefFile extends NeoSerializable { public static NefFile readFromFile(File nefFile) throws DeserializationException, IOException { int nefFileSize = (int) nefFile.length(); if (nefFileSize > 0x100000) { throw new IllegalArgumentException("The given NEF file is too large. File was " + nefFileSize + " bytes, but a max of 2^20 bytes is allowed."); } try (FileInputStream nefStream = new FileInputStream(nefFile)) { BinaryReader reader = new BinaryReader(nefStream); return reader.readSerializable(NefFile.class); } } NefFile();  NefFile(String compiler, Version version, byte[] script); String getCompiler(); Version getVersion(); ScriptHash getScriptHash(); byte[] getCheckSum(); byte[] getScript(); @Override int getSize(); @Override void serialize(BinaryWriter writer); @Override void deserialize(BinaryReader reader); static byte[] computeChecksum(NefFile file); static NefFile readFromFile(File nefFile); public ScriptHash scriptHash; public byte[] checkSum; public byte[] script; }