Exemple #1
0
        private bool CompareAgreements(Agreement newAgreement, Agreement oldAgreement)
        {
            var agreementId = newAgreement.AgreementId;

            //exclude all lists and objects with nested collections
            //we assume that there can be chain reorganization that affects value of block number and block timestamp
            //Standard fluent assertion workflow is not applicable as we want to continue comparison even after AssertionException
            //use single & to check all conditions and write logs about all differences
            //agreements are not equal if one of these comparisons will fail
            //same solution in methods below
            bool areEqual =
                DataValidationUtils.CompareEntities(newAgreement.interestRate, oldAgreement.interestRate, agreementId, decimal.Equals, "interest rate") &
                DataValidationUtils.CompareEntities(newAgreement.loanTerm, oldAgreement.loanTerm, agreementId, LoanTermsAreEqual, "loan term") &
                DataValidationUtils.CompareEntities(newAgreement.totalAmountToRepay, oldAgreement.totalAmountToRepay, agreementId, string.Equals, "total amount to repay") &
                DataValidationUtils.CompareEntities(newAgreement.dharmaFields, oldAgreement.dharmaFields, agreementId, DharmaFieldsAreEqual, "dharma fields") &
                DataValidationUtils.CompareEntities(newAgreement.networkId, oldAgreement.networkId, agreementId, string.Equals, "network id") &
                DataValidationUtils.CompareEntities(newAgreement.blockTimeStamp, oldAgreement.blockTimeStamp, agreementId, CompareBlockTimestamps, "block timestamp") &
                DataValidationUtils.CompareEntities(newAgreement.blockNumber, oldAgreement.blockNumber, agreementId, CompareBlockNumber, "block number");

            if (
                !MakerDaoValidation.CompareMakerDaoFields(newAgreement.makerDaoFields, oldAgreement.makerDaoFields, agreementId) |
                !DataValidationUtils.CompareCollections(newAgreement.collateralModifications, oldAgreement.collateralModifications, agreementId, CollateralModificationsMatcher, "collateral") |
                !DataValidationUtils.CompareCollections(newAgreement.repayments, oldAgreement.repayments, agreementId, RepaymentsMatcher, "repayment") |
                !DataValidationUtils.CompareCollections(newAgreement.issuances, oldAgreement.issuances, agreementId, IssuancesMatcher, "issuance")
                )
            {
                areEqual = false;
            }

            return(areEqual);
        }
Exemple #2
0
        public static bool CompareMakerDaoFields(MakerDaoFields newMakerDaoFields, MakerDaoFields oldMakerDaoFields, string agreementId)
        {
            bool areEqual = true;

            //case when it's not makerDao agreement
            if (newMakerDaoFields == null && oldMakerDaoFields == null)
            {
                return(true);
            }

            //incorrect case when only one object is null
            if (newMakerDaoFields == null || oldMakerDaoFields == null)
            {
                Console.WriteLine($"For agreement id {agreementId} new agreement maker dao fields are {JsonConvert.SerializeObject(newMakerDaoFields)}" +
                                  $"and for the old one {JsonConvert.SerializeObject(oldMakerDaoFields)}");
                return(false);
            }

            if (
                !DataValidationUtils.CompareEntities(newMakerDaoFields.creatorAddress, oldMakerDaoFields.creatorAddress, agreementId, string.Equals, "creatorAddress") |
                !DataValidationUtils.CompareEntities(newMakerDaoFields.ownerAddress, oldMakerDaoFields.ownerAddress, agreementId, string.Equals, "ownerAddress") |
                !DataValidationUtils.CompareEntities(newMakerDaoFields.shut, oldMakerDaoFields.shut, agreementId, ShutsAreEqual, "shut")
                )
            {
                areEqual = false;
            }

            if (
                !DataValidationUtils.CompareCollections(newMakerDaoFields.ownerUpdates, oldMakerDaoFields.ownerUpdates, agreementId, OwnerUpdatesMatcher, "owner update") |
                !DataValidationUtils.CompareCollections(newMakerDaoFields.bites, oldMakerDaoFields.bites, agreementId, BitesMatcher, "bite") |
                !DataValidationUtils.CompareCollections(newMakerDaoFields.governanceFees, oldMakerDaoFields.governanceFees, agreementId, FeesMatcher, "governance fee") |
                !DataValidationUtils.CompareCollections(newMakerDaoFields.liquidationFees, oldMakerDaoFields.liquidationFees, agreementId, FeesMatcher, "liquidation fee") |
                !DataValidationUtils.CompareCollections(newMakerDaoFields.interestFeeUpdates, oldMakerDaoFields.interestFeeUpdates, agreementId, InterestFeesMatcher, "interest fee update") |
                !DataValidationUtils.CompareCollections(newMakerDaoFields.rates, oldMakerDaoFields.rates, agreementId, RatesMatcher, "rates")
                )
            {
                areEqual = false;
            }

            return(areEqual);
        }