Skip to content

Commit

Permalink
refactor data model for test trade context
Browse files Browse the repository at this point in the history
use object-oriented context for tests
factor out trade peer context to TradePeer
test expected balances end-to-end
test split output fee if maker reserves exact amount
  • Loading branch information
woodser committed Oct 27, 2023
1 parent 708fb3c commit 4f2a7b6
Show file tree
Hide file tree
Showing 7 changed files with 1,078 additions and 564 deletions.
8 changes: 8 additions & 0 deletions dist/protobuf/grpc_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,12 @@ export class OfferInfo extends jspb.Message {
getArbitratorSigner(): string;
setArbitratorSigner(value: string): OfferInfo;

getSplitOutputTxHash(): string;
setSplitOutputTxHash(value: string): OfferInfo;

getSplitOutputTxFee(): string;
setSplitOutputTxFee(value: string): OfferInfo;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): OfferInfo.AsObject;
static toObject(includeInstance: boolean, msg: OfferInfo): OfferInfo.AsObject;
Expand Down Expand Up @@ -1700,6 +1706,8 @@ export namespace OfferInfo {
versionNr: string,
protocolVersion: number,
arbitratorSigner: string,
splitOutputTxHash: string,
splitOutputTxFee: string,
}
}

Expand Down
62 changes: 61 additions & 1 deletion dist/protobuf/grpc_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -15339,7 +15339,9 @@ proto.io.haveno.protobuffer.OfferInfo.toObject = function(includeInstance, msg)
pubKeyRing: jspb.Message.getFieldWithDefault(msg, 24, ""),
versionNr: jspb.Message.getFieldWithDefault(msg, 25, ""),
protocolVersion: jspb.Message.getFieldWithDefault(msg, 26, 0),
arbitratorSigner: jspb.Message.getFieldWithDefault(msg, 27, "")
arbitratorSigner: jspb.Message.getFieldWithDefault(msg, 27, ""),
splitOutputTxHash: jspb.Message.getFieldWithDefault(msg, 28, ""),
splitOutputTxFee: jspb.Message.getFieldWithDefault(msg, 29, "0")
};

if (includeInstance) {
Expand Down Expand Up @@ -15484,6 +15486,14 @@ proto.io.haveno.protobuffer.OfferInfo.deserializeBinaryFromReader = function(msg
var value = /** @type {string} */ (reader.readString());
msg.setArbitratorSigner(value);
break;
case 28:
var value = /** @type {string} */ (reader.readString());
msg.setSplitOutputTxHash(value);
break;
case 29:
var value = /** @type {string} */ (reader.readUint64String());
msg.setSplitOutputTxFee(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -15702,6 +15712,20 @@ proto.io.haveno.protobuffer.OfferInfo.serializeBinaryToWriter = function(message
f
);
}
f = message.getSplitOutputTxHash();
if (f.length > 0) {
writer.writeString(
28,
f
);
}
f = message.getSplitOutputTxFee();
if (parseInt(f, 10) !== 0) {
writer.writeUint64String(
29,
f
);
}
};


Expand Down Expand Up @@ -16191,6 +16215,42 @@ proto.io.haveno.protobuffer.OfferInfo.prototype.setArbitratorSigner = function(v
};


/**
* optional string split_output_tx_hash = 28;
* @return {string}
*/
proto.io.haveno.protobuffer.OfferInfo.prototype.getSplitOutputTxHash = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 28, ""));
};


/**
* @param {string} value
* @return {!proto.io.haveno.protobuffer.OfferInfo} returns this
*/
proto.io.haveno.protobuffer.OfferInfo.prototype.setSplitOutputTxHash = function(value) {
return jspb.Message.setProto3StringField(this, 28, value);
};


/**
* optional uint64 split_output_tx_fee = 29;
* @return {string}
*/
proto.io.haveno.protobuffer.OfferInfo.prototype.getSplitOutputTxFee = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 29, "0"));
};


/**
* @param {string} value
* @return {!proto.io.haveno.protobuffer.OfferInfo} returns this
*/
proto.io.haveno.protobuffer.OfferInfo.prototype.setSplitOutputTxFee = function(value) {
return jspb.Message.setProto3StringIntField(this, 29, value);
};





Expand Down
2 changes: 1 addition & 1 deletion dist/protobuf/grpc_pb.js.map

Large diffs are not rendered by default.

34 changes: 30 additions & 4 deletions dist/protobuf/pb_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,12 @@ export class DepositResponse extends jspb.Message {
getErrorMessage(): string;
setErrorMessage(value: string): DepositResponse;

getBuyersecuritydeposit(): number;
setBuyersecuritydeposit(value: number): DepositResponse;

getSellersecuritydeposit(): number;
setSellersecuritydeposit(value: number): DepositResponse;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): DepositResponse.AsObject;
static toObject(includeInstance: boolean, msg: DepositResponse): DepositResponse.AsObject;
Expand All @@ -1272,6 +1278,8 @@ export namespace DepositResponse {
uid: string,
currentDate: number,
errorMessage: string,
buyersecuritydeposit: number,
sellersecuritydeposit: number,
}
}

Expand Down Expand Up @@ -3178,6 +3186,9 @@ export class DisputeResult extends jspb.Message {
getSellerPayoutAmount(): number;
setSellerPayoutAmount(value: number): DisputeResult;

getSubtractFeeFrom(): DisputeResult.SubtractFeeFrom;
setSubtractFeeFrom(value: DisputeResult.SubtractFeeFrom): DisputeResult;

getArbitratorPubKey(): Uint8Array | string;
getArbitratorPubKey_asU8(): Uint8Array;
getArbitratorPubKey_asB64(): string;
Expand Down Expand Up @@ -3211,6 +3222,7 @@ export namespace DisputeResult {
arbitratorSignature: Uint8Array | string,
buyerPayoutAmount: number,
sellerPayoutAmount: number,
subtractFeeFrom: DisputeResult.SubtractFeeFrom,
arbitratorPubKey: Uint8Array | string,
closeDate: number,
isLoserPublisher: boolean,
Expand All @@ -3237,6 +3249,12 @@ export namespace DisputeResult {
TRADE_ALREADY_SETTLED = 11,
PEER_WAS_LATE = 12,
}

export enum SubtractFeeFrom {
BUYER_ONLY = 0,
SELLER_ONLY = 1,
BUYER_AND_SELLER = 2,
}
}

export class Contract extends jspb.Message {
Expand Down Expand Up @@ -5860,6 +5878,12 @@ export class OpenOffer extends jspb.Message {
getReserveExactAmount(): boolean;
setReserveExactAmount(value: boolean): OpenOffer;

getSplitOutputTxHash(): string;
setSplitOutputTxHash(value: string): OpenOffer;

getSplitOutputTxFee(): number;
setSplitOutputTxFee(value: number): OpenOffer;

getScheduledTxHashesList(): Array<string>;
setScheduledTxHashesList(value: Array<string>): OpenOffer;
clearScheduledTxHashesList(): OpenOffer;
Expand All @@ -5868,9 +5892,6 @@ export class OpenOffer extends jspb.Message {
getScheduledAmount(): string;
setScheduledAmount(value: string): OpenOffer;

getSplitOutputTxHash(): string;
setSplitOutputTxHash(value: string): OpenOffer;

getReserveTxHash(): string;
setReserveTxHash(value: string): OpenOffer;

Expand All @@ -5894,9 +5915,10 @@ export namespace OpenOffer {
state: OpenOffer.State,
triggerPrice: number,
reserveExactAmount: boolean,
splitOutputTxHash: string,
splitOutputTxFee: number,
scheduledTxHashesList: Array<string>,
scheduledAmount: string,
splitOutputTxHash: string,
reserveTxHash: string,
reserveTxHex: string,
reserveTxKey: string,
Expand Down Expand Up @@ -6521,6 +6543,9 @@ export class TradePeer extends jspb.Message {
getDepositTxKey(): string;
setDepositTxKey(value: string): TradePeer;

getDepositTxFee(): number;
setDepositTxFee(value: number): TradePeer;

getSecurityDeposit(): number;
setSecurityDeposit(value: number): TradePeer;

Expand Down Expand Up @@ -6567,6 +6592,7 @@ export namespace TradePeer {
depositTxHash: string,
depositTxHex: string,
depositTxKey: string,
depositTxFee: number,
securityDeposit: number,
updatedMultisigHex: string,
depositsConfirmedMessageAcked: boolean,
Expand Down
Loading

0 comments on commit 4f2a7b6

Please sign in to comment.