當前位置: 首頁>>代碼示例>>Java>>正文


Java Stack類代碼示例

本文整理匯總了Java中org.ethereum.vm.program.Stack的典型用法代碼示例。如果您正苦於以下問題:Java Stack類的具體用法?Java Stack怎麽用?Java Stack使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Stack類屬於org.ethereum.vm.program包,在下文中一共展示了Stack類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPush1

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void testPush1() {
    Program program = executeCode("PUSH1 0xa0", 1);
    Stack stack = program.getStack();

    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(0xa0), stack.peek());
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:9,代碼來源:VMExecutionTest.java

示例2: testAdd

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void testAdd() {
    Program program = executeCode("PUSH1 1 PUSH1 2 ADD", 3);
    Stack stack = program.getStack();

    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(3), stack.peek());
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:9,代碼來源:VMExecutionTest.java

示例3: testMul

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void testMul() {
    Program program = executeCode("PUSH1 3 PUSH1 2 MUL", 3);
    Stack stack = program.getStack();

    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(6), stack.peek());
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:9,代碼來源:VMExecutionTest.java

示例4: testSub

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void testSub() {
    Program program = executeCode("PUSH1 1 PUSH1 2 SUB", 3);
    Stack stack = program.getStack();

    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:9,代碼來源:VMExecutionTest.java

示例5: testJumpSkippingInvalidJump

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void testJumpSkippingInvalidJump() {
    Program program = executeCode("PUSH1 0x05 JUMP PUSH1 0xa0 JUMPDEST PUSH1 0x01", 4);
    Stack stack = program.getStack();

    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:9,代碼來源:VMExecutionTest.java

示例6: dupnFirstItem

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void dupnFirstItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x00 DUPN", 3);
    Stack stack = program.getStack();

    Assert.assertEquals(2, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
    Assert.assertEquals(new DataWord(1), stack.get(0));
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:10,代碼來源:VMExecutionTest.java

示例7: dupnFourthItem

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void dupnFourthItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x03 DUPN", 6);
    Stack stack = program.getStack();

    Assert.assertEquals(5, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());

    for (int k = 0; k < 4; k++)
        Assert.assertEquals(new DataWord(k + 1), stack.get(k));
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:12,代碼來源:VMExecutionTest.java

示例8: dupnTwentiethItem

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void dupnTwentiethItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x05 PUSH1 0x06 PUSH1 0x07 PUSH1 0x08 PUSH1 0x09 PUSH1 0x0a PUSH1 0x0b PUSH1 0x0c PUSH1 0x0d PUSH1 0x0e PUSH1 0x0f PUSH1 0x10 PUSH1 0x11 PUSH1 0x12 PUSH1 0x13 PUSH1 0x14 PUSH1 0x13 DUPN", 22);
    Stack stack = program.getStack();

    Assert.assertEquals(21, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());

    for (int k = 0; k < 20; k++)
        Assert.assertEquals(new DataWord(k + 1), stack.get(k));
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:12,代碼來源:VMExecutionTest.java

示例9: swapnSecondItem

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void swapnSecondItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x00 SWAPN", 4);
    Stack stack = program.getStack();

    Assert.assertEquals(2, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
    Assert.assertEquals(new DataWord(2), stack.get(0));
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:10,代碼來源:VMExecutionTest.java

示例10: swapnFourthItem

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void swapnFourthItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x02 SWAPN", 6);
    Stack stack = program.getStack();

    Assert.assertEquals(4, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
    Assert.assertEquals(new DataWord(4), stack.get(0));
    Assert.assertEquals(new DataWord(2), stack.get(1));
    Assert.assertEquals(new DataWord(3), stack.get(2));
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:12,代碼來源:VMExecutionTest.java

示例11: swapnTwentiethItem

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void swapnTwentiethItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x05 PUSH1 0x06 PUSH1 0x07 PUSH1 0x08 PUSH1 0x09 PUSH1 0x0a PUSH1 0x0b PUSH1 0x0c PUSH1 0x0d PUSH1 0x0e PUSH1 0x0f PUSH1 0x10 PUSH1 0x11 PUSH1 0x12 PUSH1 0x13 PUSH1 0x14 PUSH1 0x12 SWAPN", 22);
    Stack stack = program.getStack();

    Assert.assertEquals(20, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
    Assert.assertEquals(new DataWord(20), stack.get(0));

    for (int k = 1; k < 19; k++)
        Assert.assertEquals(new DataWord(k + 1), stack.get(k));
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:13,代碼來源:VMExecutionTest.java

示例12: txindexExecution

import org.ethereum.vm.program.Stack; //導入依賴的package包/類
@Test
public void txindexExecution() {
    invoke.setTransactionIndex(new DataWord(42));
    Program program = executeCode("TXINDEX", 1);
    Stack stack = program.getStack();

    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(42), stack.peek());
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:10,代碼來源:VMExecutionTest.java


注:本文中的org.ethereum.vm.program.Stack類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。