Skip to content

Commit

Permalink
Merge pull request #139 from ardriveapp/PE-659_private_file_reward_fix
Browse files Browse the repository at this point in the history
fix(priv upload): Use alternate encrypted estimation algorithm PE-477
  • Loading branch information
fedellen authored Nov 4, 2021
2 parents 805bbe4 + 4d08533 commit b13e1ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ardrive-cli",
"version": "1.0.1",
"version": "1.0.2",
"description": "The ArDrive Command Line Interface (CLI is a Node.js application for terminal-based ArDrive workflows. It also offers utility operations for securely interacting with Arweave wallets and inspecting various Arweave blockchain conditions.",
"main": "./lib/index.js",
"bin": {
Expand Down
4 changes: 2 additions & 2 deletions src/ardrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,8 @@ export class ArDrive extends ArDriveAnonymous {
if (dataSize > Number.MAX_SAFE_INTEGER - 16) {
throw new Error(`Max un-encrypted dataSize allowed is ${Number.MAX_SAFE_INTEGER - 16}!`);
}
const modulo16 = dataSize % 16;
return dataSize - modulo16 + 16;

return (dataSize / 16 + 1) * 16;
}

async uploadPrivateFile(
Expand Down
10 changes: 5 additions & 5 deletions src/utils/ardrive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ describe('ArDrive class', () => {
it('returns the expected values for valid inputs', () => {
const inputsAndExpectedOutputs = [
[0, 16],
[1, 16],
[15, 16],
[1, 17],
[15, 31],
[16, 32],
[17, 32],
[Number.MAX_SAFE_INTEGER - 16, Number.MAX_SAFE_INTEGER - 15]
[17, 33],
[Number.MAX_SAFE_INTEGER - 16, Number.MAX_SAFE_INTEGER]
];
inputsAndExpectedOutputs.forEach(([input, expectedOutput]) => {
expect(arDrive.encryptedDataSize(input)).to.equal(expectedOutput);
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('ArDrive class', () => {
);
expect(actual).to.deep.equal({
metaDataBaseReward: '147',
fileDataBaseReward: '1234576',
fileDataBaseReward: '1234583',
communityWinstonTip: '9876543210'
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ardrive.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,15 @@ describe('ArDrive class - integrated', () => {
);

// Pass expected existing file id, so that the file would be considered a revision
assertUploadFileExpectations(result, 3216, 187, 0, '1', 'private', existingFileId);
assertUploadFileExpectations(result, 3220, 187, 0, '1', 'private', existingFileId);
});

it('returns the correct ArFSResult', async () => {
stub(arfsDao, 'getOwnerForDriveId').resolves(walletOwner);
const stubDriveKey = await getStubDriveKey();

const result = await arDrive.uploadPrivateFile(stubEntityID, wrappedFile, stubDriveKey);
assertUploadFileExpectations(result, 3216, 182, 0, '1', 'private');
assertUploadFileExpectations(result, 3220, 182, 0, '1', 'private');
});
});

Expand Down

0 comments on commit b13e1ca

Please sign in to comment.