示例#1
0
    static void Main()
    {
        int y;

        foo(out y);
        Contract.Assert(y != 10);

        int  witness;
        CaaS paypal = GlobalState.paypal;
        PayPalStandardPaymentProcessor1 merchant_sender = new PayPalStandardPaymentProcessor1();

        PayPalStandardReturn1 merchant_receiver = new PayPalStandardReturn1();
        Order init_order = p.NondetOrder();
        canonicalRequestResponse res_placeorder = p.NodetReqres();
        canonicalRequestResponse req_pay        = p.NodetReqres();
        canonicalRequestResponse res_pay        = p.NodetReqres();
        canonicalRequestResponse req_finish     = p.NodetReqres();

        // Computation on merchant - place order
        res_placeorder = merchant_sender.PostProcessPayment(init_order);
        // Message: merchant -> client -> CaaS
        // is the msg encrypted? if so, then:
        req_pay = res_placeorder;
        GlobalState.MerchantPaymentEmail = req_pay.payee;
        GlobalState.order.gross          = req_pay.gross;
        GlobalState.order.id             = req_pay.orderID;

        GlobalState.paypal.pay(req_pay); //Rui: there is no return for this call, because anything returned through the client should be havoced

        req_finish.orderID = p.NondetInt();
        witness            = merchant_receiver.Page_Load(null, null, req_finish.orderID);

        Contract.Assert(GlobalState.paypal.caas.payments[witness].orderID == req_finish.orderID);
        Contract.Assert(
            paypal.caas.payments[witness].orderID == req_finish.orderID &&
            paypal.caas.payments[witness].gross == GlobalState.tstore.orders[req_finish.orderID].gross &&
            paypal.caas.payments[witness].payee == GlobalState.tstore.myAccount &&
            paypal.caas.payments[witness].status == CaasReturnStatus.Sucess
            );
        Contract.Assert(0 <= witness && witness < paypal.caas.payments.Length);

        Contract.Assert(Contract.Exists(0, paypal.caas.payments.Length, i =>
                                        paypal.caas.payments[i].orderID == req_finish.orderID &&
                                        paypal.caas.payments[i].payee == GlobalState.tstore.myAccount &&
                                        paypal.caas.payments[i].status == CaasReturnStatus.Sucess &&
                                        paypal.caas.payments[i].gross == GlobalState.tstore.orders[req_finish.orderID].gross
                                        ));
    }
示例#2
0
    static void Main()
    {
        PayPalStandardPaymentProcessor1 merchant_sender = new PayPalStandardPaymentProcessor1();

        PayPalStandardReturn1 merchant_receiver = new PayPalStandardReturn1();
        Order init_order = p.NondetOrder();

        GlobalState.order   = new orderRecord();
        GlobalState.payment = new orderRecord();
        canonicalRequestResponse res_placeorder = p.NodetReqres();
        canonicalRequestResponse req_pay        = p.NodetReqres();
        canonicalRequestResponse res_pay        = p.NodetReqres();
        canonicalRequestResponse req_finish     = p.NodetReqres();

        // Message: CaaS -> client -> merchant
        // Computation on merchant - finish order
        merchant_receiver.Page_Load(null, null);

        Contract.Assert(GlobalState.order.id == GlobalState.payment.id);
        Contract.Assert(GlobalState.MerchantPaymentEmail == GlobalState.payment.payee);
        Contract.Assert(GlobalState.order.gross == GlobalState.payment.gross);
        Contract.Assert(GlobalState.order.status == Global.OrderStatusEnum.Paid);
    }