Skip to content

Commit

Permalink
add further code metadata test
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Nov 16, 2023
1 parent a2146ba commit 281f651
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/smartcontracts/codeMetadata.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("CodeMetadata Class Tests", function() {
assert.equal(buffer[1], ByteOne.Payable | ByteOne.PayableBySc);
});

it("should create from buffer correctly", function() {
it("should create from buffer correctly when all flags are set", function() {
const buffer = Buffer.from([ByteZero.Upgradeable | ByteZero.Readable, ByteOne.Payable | ByteOne.PayableBySc]);
const metadata = CodeMetadata.fromBuffer(buffer);

Expand All @@ -42,6 +42,16 @@ describe("CodeMetadata Class Tests", function() {
assert.isTrue(metadata.payableBySc);
});

it.only("should create from buffer correctly when some flags are set", function() {
const buffer = Buffer.from([ByteZero.Upgradeable, ByteOne.PayableBySc]);
const metadata = CodeMetadata.fromBuffer(buffer);

assert.isTrue(metadata.upgradeable);
assert.isFalse(metadata.readable);
assert.isFalse(metadata.payable);
assert.isTrue(metadata.payableBySc);
});

it("should handle buffer too short error", function() {
const buffer = Buffer.from([ByteZero.Upgradeable]);

Expand Down

0 comments on commit 281f651

Please sign in to comment.